Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#2133 closed change (fixed)

[cms] Allow to specify default translation inline in pages rather than in a separate file

Reported by: trev Assignee: trev
Priority: P4 Milestone:
Module: Sitescripts Keywords:
Cc: Blocked By:
Blocking: #2035, #2111 Platform: Unknown
Ready: yes Confidential: no
Tester: Verified working: yes
Review URL(s):

http://codereview.adblockplus.org/5694103719247872/

Description (last modified by trev)

Background

Currently, we require all translations to be inside .json files. While this makes uploading translations to Crowdin easier, it also means that editing page files is very complicated - one has to constantly match string references to the strings in the locale file.

What to change

Allow specifying the default translation (typically English) inline in the page. The format should be as follows:

Raw HTML:

<p>{{click_text Click <a href="data:">here</a>.}}

<p>{{click_text[Optional comment for translators] Click <a href="data:">here</a>.}}

Markdown:

<p>{{click_text Click [here](data:).}}

<p>{{click_text[Optional comment for translators] Click [here](data:).}}

Jinja2 template:

<p>{{'Click <a href="data:">here</a>.'|translate("click_text")}}

<p>{{'Click <a href="data:">here</a>.'|translate("click_text", comment="Optional comment for translators")}}

In some cases, Jinja2 templates will still need to read data from a locale file. No default will be specified then, meaning that a .json file is still required for English here:

<p>{{get_string("toc_title", "interface")}}</p>

Note that there is a conceptual change here: currently, the CMS looks at the locale files whenever it needs to determine which locales are available for a page. Now it has to assume that each page is automatically available in the default locale, regardless of whether a corresponding locale file exists.

Change History (5)

comment:1 Changed 4 years ago by trev

  • Description modified (diff)

comment:2 Changed 4 years ago by trev

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:3 Changed 4 years ago by trev

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:4 Changed 4 years ago by trev

  • Blocking 2105 removed

comment:5 Changed 4 years ago by Ross

  • Verified working set

Implemented and working.

Tested by:
Creating a CMS page and creating various translatable links (HTML, Markdown, Jinja). Also running the website converter script as per the read me and checking the output.

Tested with:
www / r18024
sitescripts / r501
web.adblockplus.org / r68
website-converter / master / 105208883c4336a3788820fe9ab379cf639f8387

Note: See TracTickets for help on using tickets.