Translation issueshttps://lab.civicrm.org/dev/translation/-/issues2018-10-22T18:50:53Zhttps://lab.civicrm.org/dev/translation/-/issues/17RTL issue: form label should be at right, and their input fields, at the left.2018-10-22T18:50:53ZcalbasiRTL issue: form label should be at right, and their input fields, at the left.I'm not sure if I should create this issue here or at civicrm core repository. Doing here, as first step to make a Merge Request at Github repository.
I'm attaching an screenshot of the wrong output. It's wrong, at least, in Arabic, but...I'm not sure if I should create this issue here or at civicrm core repository. Doing here, as first step to make a Merge Request at Github repository.
I'm attaching an screenshot of the wrong output. It's wrong, at least, in Arabic, but I suppose it's wrong for all other RTL languages. It's, too, a basic feature, because forms are used everywhere...
This issue happens at custom profile but also at system/default profiles.![Captura_2018-09-13_17-20-29](/uploads/3bdba1980909fd4fb5a0ea96979bd24d/Captura_2018-09-13_17-20-29.png)
![Captura_2018-09-13_17-17-19](/uploads/e6b36a362c68005b37c0a74e0d106194/Captura_2018-09-13_17-17-19.png)https://lab.civicrm.org/dev/translation/-/issues/7Update Localizing Documentation (Drupal configurations)2019-01-14T15:52:50ZshaneonabikeUpdate Localizing Documentation (Drupal configurations)There is some special mapping configurations for multilingual Drupal sites to map the proper languages between Drupal and CiviCRM. Is there a way I could update the existing documentation?
https://docs.civicrm.org/user/en/latest/the-civ...There is some special mapping configurations for multilingual Drupal sites to map the proper languages between Drupal and CiviCRM. Is there a way I could update the existing documentation?
https://docs.civicrm.org/user/en/latest/the-civicrm-community/localising-civicrm/
`"Inherit CMS language" and regional translations (ex: fr_CA)
If you have a multi-lingual site and you are using the "inherit CMS language" configuration option, but wish to, for example, use fr_CA instead of the default fr_FR (for French), you can define a constant in your "civicrm.settings.php" to override the default behavior.
See CRM-9558 for more information.
define('CIVICRM_LANGUAGE_MAPPING_FR', 'fr_CA');
`
From https://wiki.civicrm.org/confluence/display/CRMDOC/i18n+Administrator%27s+Guide%3A+Using+CiviCRM+in+your+own+languagehttps://lab.civicrm.org/dev/translation/-/issues/24On New Event, allow translations to be entered before first save2019-03-08T17:14:15ZJoeMurrayOn New Event, allow translations to be entered before first saveCurrently, on multilingual sites, it is only possible to enter text for the current language on the first form presented for Events > New Event (civicrm/event/add?reset=1&action=add). After that form is saved, translations can be entered...Currently, on multilingual sites, it is only possible to enter text for the current language on the first form presented for Events > New Event (civicrm/event/add?reset=1&action=add). After that form is saved, translations can be entered for any translatable field on any tab.
Proposed enhancement: allow translations to be entered for the text fields on the first form as well, prior to first save.
This enhancement idea is currently unfunded.https://lab.civicrm.org/dev/translation/-/issues/42Document guidelines for situations where trivial technical changes do more ha...2020-04-02T13:28:24ZDaveDDocument guidelines for situations where trivial technical changes do more harm than goodMoved to gitlab from https://github.com/civicrm/civicrm-dev-docs/pull/754
The [end-to-end process](https://lab.civicrm.org/dev/translation/-/wikis/Pushing-new-strings-to-transifex) from the time you make a change in the code to when the...Moved to gitlab from https://github.com/civicrm/civicrm-dev-docs/pull/754
The [end-to-end process](https://lab.civicrm.org/dev/translation/-/wikis/Pushing-new-strings-to-transifex) from the time you make a change in the code to when the translation of it ends up in the tarball of a release is lengthy, depends on human translators' time, and currently includes a [manual tedious step](https://lab.civicrm.org/infra/ops/-/issues/931) for administrators (which means it doesn't even get to transifex to be made available to translators for a few months). In the meantime the string you just changed has now potentially become untranslated immediately in all languages in both master and likely still untranslated when it becomes a release candidate. And possibly for several releases/months after.
So if the wording is not preventing users from completing tasks and the technical functionality is working, then is having it be EXACTLY right worth invalidating an existing translation and generating another end-to-end cycle of the translation process *if that is the only change being made*. It seems like it is possible to write out some guidelines and examples.
The PR proposed these as a starting point:
#### Don't change
```smarty
{ts 1="https://www.example.org"}This is a block of text where the wording is fine and the link works but the <a href="%1" target="_blank">link attributes</a> should be a parameter to the ts. But it's not preventing anyone completing their work tasks and isn't confusing to users.{/ts}
```
#### Do change
* If it would normally break translation but the new string is already used somewhere else, and so it's already translated.
* Spelling mistakes. While not preventing a user from completing a task, the positives outweigh the negatives, and this is visible to the user, as compared to the above "don't change" example where the user doesn't see a problem.https://lab.civicrm.org/dev/translation/-/issues/44When you have multiple available languages using the language switcher on an ...2020-04-14T14:46:25ZDaveDWhen you have multiple available languages using the language switcher on an angular page gives page not foundI thought I'd seen this reported already but can't find it. Maybe I was thinking of https://lab.civicrm.org/dev/translation/-/issues/23 which is maybe related but seems a bit different. The issue here is the resulting url.
1. On the loc...I thought I'd seen this reported already but can't find it. Maybe I was thinking of https://lab.civicrm.org/dev/translation/-/issues/23 which is maybe related but seems a bit different. The issue here is the resulting url.
1. On the localization page add another language in the "Available languages" field.
1. Visit an angular page like Admin - CiviCase - Case Types.
1. Using the language switcher (on drupal 7 it's in the left sidebar), change the language.
1. It will change the language, but you get a page that just says "Unknown path".https://lab.civicrm.org/dev/translation/-/issues/31civicrm_mailing_component name is limited to 64 charaters, missing label2020-05-18T00:29:46Zbgmcivicrm_mailing_component name is limited to 64 charaters, missing labelThe `civicrm_mailing_component` has a `name` column limited to varchar(64). This name column is exposed to users, and extracted for translation.
However, in some languages the translation for some of the strings, such as "resubscribe me...The `civicrm_mailing_component` has a `name` column limited to varchar(64). This name column is exposed to users, and extracted for translation.
However, in some languages the translation for some of the strings, such as "resubscribe message" can be over 64 characters, causing the CiviCRM installer to fail.https://lab.civicrm.org/dev/translation/-/issues/46Proposal - languages from urls2020-05-26T20:15:41ZeileenProposal - languages from urlsI want to propose an addition to our basic edit forms
1) in CRM_Core_Form -add a property language and in generic preProcess look for this property in the url & set it on the form
2) in any APIv4 calls at the form layer use this value t...I want to propose an addition to our basic edit forms
1) in CRM_Core_Form -add a property language and in generic preProcess look for this property in the url & set it on the form
2) in any APIv4 calls at the form layer use this value to setLanguage, if exists, on the api call (this is mostly a principle of intent at this stage)
What does this achieve? Basically it allows me to take action in an extension. Currently the MessageTemplate form uses apiv4 to retrieve and save message templates. I can listen to these calls in civi_data_translate_civicrm_apiWrappers and intervene - retrieving the values relevant to the specific language, if appropriate. This is a pretty tough intervention to do without any core support, and fairly simple with a small change to core + an agreement as to how we prefer to use the api going forwards
https://github.com/eileenmcnaughton/civi-data-translate/blob/master/civi_data_translate.php#L187
Next steps - I would look to convert the EntityFormTrait to use apiv4 to create a generic template / model for how this should be done. (I would need to set api version as a parameter on the form as I realise extensions may use this trait for entities with no v4 api as yet.)
@bgm @colemanw @seamuslee @tottenhttps://lab.civicrm.org/dev/translation/-/issues/49Multi-record Custom Data Money Field is not formatted2020-06-12T14:24:00ZbgmMulti-record Custom Data Money Field is not formattedSteps to re-create:
* Create a new Custom Field Group, for Contacts, with multi-record enabled.
* Add a money field (text) in that group.
Then go to a contact record, and create a record with a money amount.
Result:
![civicrm-custom-...Steps to re-create:
* Create a new Custom Field Group, for Contacts, with multi-record enabled.
* Add a money field (text) in that group.
Then go to a contact record, and create a record with a money amount.
Result:
![civicrm-custom-value-formatting](/uploads/6f44d0c3eecfbf7ce0471ed87b2eb49b/civicrm-custom-value-formatting.png)
Expected result: $123.44
When we view the record, it displays correctly:
![Capture_d_écran_de_2020-06-10_12-52-10](/uploads/6cefeae38392e7681effe4c298064db9/Capture_d_écran_de_2020-06-10_12-52-10.png)
I narrowed it down to `CRM_Profile_Page_MultipleRecordFieldsListing::browse()`, but it feels like a mine field.https://lab.civicrm.org/dev/translation/-/issues/8Multilingual installation with logging enabled gives error when custom field ...2020-07-14T14:56:53ZtbuytaerMultilingual installation with logging enabled gives error when custom field is changedLogging of custom fields on a multilingual installation does not work, which makes it impossible to view changes if one of the changes is a custom field.
Steps to reproduce:
1. install a fresh CiviCRM installation: 5.0 (the issue also ...Logging of custom fields on a multilingual installation does not work, which makes it impossible to view changes if one of the changes is a custom field.
Steps to reproduce:
1. install a fresh CiviCRM installation: 5.0 (the issue also existed in versions before)
2. enable **Multiple Languages Support** on http://example.org/civicrm/admin/setting/localization?reset=1
3. enable **logging** on http://example.org/civicrm/admin/setting/misc?reset=1
4. change a custom field of a contact
5. view the changelog of that contact and click on the change
This results in follwing Database error:
> Database Error Code: Table 'databasename.log_civicrm_custom_group_en_US' doesn't exist, 1146
> Additional Details:
> Array
> (
> [callback] => Array
> (
> [0] => CRM_Core_Error
> [1] => handle
> )
>
> [code] => -18
> [message] => DB Error: no such table
> [mode] => 16
> [debug_info] => SELECT id, title FROM `databasename`.log_civicrm_custom_group_en_US WHERE log_date <= '2018-04-09 17:40:29' AND table_name = 'civicrm_value_constituent_information_1' ORDER BY log_date DESC LIMIT 1 [nativecode=1146 ** Table 'databasename.log_civicrm_custom_group_en_US' doesn't exist]
> [type] => DB_Error
> [user_info] => SELECT id, title FROM `databasename`.log_civicrm_custom_group_en_US WHERE log_date <= '2018-04-09 17:40:29' AND table_name = 'civicrm_value_constituent_information_1' ORDER BY log_date DESC LIMIT 1 [nativecode=1146 ** Table 'databasename.log_civicrm_custom_group_en_US' doesn't exist]
> [to_string] => [db_error: message="DB Error: no such table" code=-18 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT id, title FROM `databasename`.log_civicrm_custom_group_en_US WHERE log_date <= '2018-04-09 17:40:29' AND table_name = 'civicrm_value_constituent_information_1' ORDER BY log_date DESC LIMIT 1 [nativecode=1146 ** Table 'databasename.log_civicrm_custom_group_en_US' doesn't exist]"]
> )
*I replaced the actual database name with 'databasename' in the error message above*https://lab.civicrm.org/dev/translation/-/issues/1Distribution and management of l10n/xx_YY/settings.default.json files2020-08-11T11:18:57ZbgmDistribution and management of l10n/xx_YY/settings.default.json filesNow that CRM-16395 has been merged, we can provide localised setting files for supported languages.
Now we need to:
* [x] decide where to store (in the 'l10n' git repo) the settings files
* [x] bundle those json files in civicrm-5.x.xx...Now that CRM-16395 has been merged, we can provide localised setting files for supported languages.
Now we need to:
* [x] decide where to store (in the 'l10n' git repo) the settings files
* [x] bundle those json files in civicrm-5.x.xx-l10n.tar.gz
* [x] document the process by which people can send/update setting files
* [ ] update the documentation about non-English installation?
Example:
https://github.com/civicrm/civicrm-core/files/305643/settings.default.json.txthttps://lab.civicrm.org/dev/translation/-/issues/57Mixed up translation for a few case role-related strings in nl_BE2020-10-23T15:08:34ZDaveDMixed up translation for a few case role-related strings in nl_BEThere are a couple lines in the nl_BE po file that are a bit mixed up. This came up before and it got fixed for nl_NL but didn't get updated for nl_BE. I think this needs to be updated in transifex.
https://lab.civicrm.org/dev/translati...There are a couple lines in the nl_BE po file that are a bit mixed up. This came up before and it got fixed for nl_NL but didn't get updated for nl_BE. I think this needs to be updated in transifex.
https://lab.civicrm.org/dev/translation/-/blob/41c36bc0532e3dd5e96e3481d6212f0c36e84686/po/nl_BE/case.po#L787-797
The nl_NL ones are correct so the corresponding lines above just need to match these:
https://lab.civicrm.org/dev/translation/-/blob/41c36bc0532e3dd5e96e3481d6212f0c36e84686/po/nl_NL/case.po#L771-781https://lab.civicrm.org/dev/translation/-/issues/50Locale-aware recaptcha2020-12-14T04:07:55Zmattwiremjw@mjwconsult.co.ukLocale-aware recaptchaThe library in use by CiviCRM is a *very* old version and is not locale-aware. See https://civicrm.stackexchange.com/questions/11533/recaptcha-update-language/37503 for more info.
We should update the library and make recaptcha in CiviC...The library in use by CiviCRM is a *very* old version and is not locale-aware. See https://civicrm.stackexchange.com/questions/11533/recaptcha-update-language/37503 for more info.
We should update the library and make recaptcha in CiviCRM respect the locale of the form.https://lab.civicrm.org/dev/translation/-/issues/62Updated State list for Taiwan2021-01-15T15:42:56ZsudomanUpdated State list for TaiwanOne of our site users would like to recommend updating the "State list" of "Country: Taiwan". Below is the recommended list from the Office of the President (<https://english.president.gov.tw/Page/106>). Our user says that it's ok to put...One of our site users would like to recommend updating the "State list" of "Country: Taiwan". Below is the recommended list from the Office of the President (<https://english.president.gov.tw/Page/106>). Our user says that it's ok to put the list under "State", even though they actually only call them city or county.
```
Taipei City
New Taipei City
Keelung City
Taoyuan City
Hsinchu City
Hsinchu County
Miaoli County
Taichung City
Changhua County
Nantou County
Yunlin County
Chiayi City
Chiayi County
Tainan City
Kaohsiung City
Pingtung County
Yilan County
Hualien County
Taitung County
Penghu County
Kinmen County
Lienchiang County
```
Thanks : )https://lab.civicrm.org/dev/translation/-/issues/63Italian translation of Household Member relationship doesn't specify which si...2021-01-29T10:58:50ZDaveDItalian translation of Household Member relationship doesn't specify which side the relationship is onIn english it's "Household Member of" to mean the individual is a member of a household (A to B), and "Household Member is" to mean the household has the individual as a member (B to A).
In italian it's "Membro del nucleo familiare" on ...In english it's "Household Member of" to mean the individual is a member of a household (A to B), and "Household Member is" to mean the household has the individual as a member (B to A).
In italian it's "Membro del nucleo familiare" on both sides, so it's not clear which way is which.
https://lab.civicrm.org/dev/translation/-/blob/14722d7fbae68eaea4214aa0f6966d635c1f4d91/po/it_IT/common-base.po#L25802-25808
Came up while looking at other stuff. I don't know what the right translation should be.https://lab.civicrm.org/dev/translation/-/issues/59Broken link and mistranslation in Italian for ACL roles page2021-03-19T15:14:05ZDaveDBroken link and mistranslation in Italian for ACL roles pageIt's just a help text link, but maybe 2 problems:
1. The use of `{docURL}` requires text you pass in to be translated already.
1. Somebody probably noticed it wasn't working and tried to adjust by putting the link into transifex, but it...It's just a help text link, but maybe 2 problems:
1. The use of `{docURL}` requires text you pass in to be translated already.
1. Somebody probably noticed it wasn't working and tried to adjust by putting the link into transifex, but it leads to a broken link: https://lab.civicrm.org/dev/translation/-/blob/9d4c4d9db3535f3816969b541c9bbe00345569a4/po/it_IT/common-base.po#L18128
This is the code:
https://github.com/civicrm/civicrm-core/blob/d1eed91c218f4c285a535275e36732f68463824b/templates/CRM/ACL/Header.tpl#L10-L14
```smarty
{capture assign=docLink}{docURL page='user/initial-set-up/permissions-and-access-control/' text='Access Control Documentation'}{/capture}
<div class="help">
<p>{ts 1=$docLink}ACLs allow you to control access to CiviCRM data. An ACL consists of an <strong>Operation</strong> (e.g. 'View' or 'Edit'), a <strong>set of data</strong> that the operation can be performed on (e.g. a group of contacts), and a <strong>Role</strong> that has permission to do this operation. Refer to the %1 for more info.{/ts}</p>
</div>
```https://lab.civicrm.org/dev/translation/-/issues/61docURL and ts, or how ConfigTaskList.tpl has odd translation strings2021-05-10T20:51:53ZbgmdocURL and ts, or how ConfigTaskList.tpl has odd translation stringsWhen running the string extraction, these strings end up in the .pot files:
```
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid "$componentTitles.CiviContribute"
msgstr ""
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid ...When running the string extraction, these strings end up in the .pot files:
```
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid "$componentTitles.CiviContribute"
msgstr ""
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid "$componentTitles.CiviPledge"
msgstr ""
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid "$componentTitles.CiviEvent"
msgstr ""
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid "$componentTitles.CiviMember"
msgstr ""
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid "$componentTitles.CiviMail"
msgstr ""
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid "$componentTitles.CiviCampaign"
msgstr ""
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid "$componentTitles.CiviCase"
msgstr ""
#: templates/CRM/Admin/Page/ConfigTaskList.tpl
msgid "$componentTitles.CiviGrant"
msgstr ""
```
To test:
```
civistrings templates/CRM/Admin/Page/ConfigTaskList.tpl
```
Is it because of an incorrect use of `ts`, or is it because civistrings should ignore crmURL?
Code:
```
<tr class="even">
<td class="tasklist nowrap" style="width: 10%;">{docURL page="user/contributions/what-is-civicontribute" text=$componentTitles.CiviContribute}</td>
<td>{ts}Online fundraising and donor management, as well as offline contribution processing and tracking.{/ts}</td>
</tr>
```
Example of docURL strings that should be extracted:
```
templates/CRM/Contribute/Form/ContributionPage/Custom.hlp:{capture assign=docLinkCustom}{docURL page="user/organising-your-data/custom-fields" text="custom fields"}{/capture}
templates/CRM/Contribute/Form/ContributionPage/Custom.hlp:{capture assign=docLinkProfile}{docURL page="user/organising-your-data/profiles" text="profiles"}{/capture}
templates/CRM/Case/Page/ConfigureError.tpl:{capture assign=docLink}{docURL page="user/case-management/set-up" text="CiviCase Setup documentation"}{/capture}
templates/CRM/Contact/Form/OnBehalfOf.tpl: {ts}Latitude and longitude may be automatically populated by enabling a Mapping Provider.{/ts} {docURL page="user/initial-set-up/installation-and-basic-set-up" text="(Refer to the Mapping and Geocoding section in the Installation and Basic Setup Chapter)"}</span>
```
I feel like we should instead use 'ts' in the docURL call, instead of assuming it. There are 22 instances where it would need fixing.
```
grep -r docURL templates/ | grep text | grep -v componentTitle
```
@totten @seamuslee Any thoughts?https://lab.civicrm.org/dev/translation/-/issues/27Translation option missing for "on behalf of label"2021-06-02T18:01:34ZMartinTranslation option missing for "on behalf of label"I might be misunderstanding how this is supposed to work, but here's the situation that I'm seeing. I have multilingual for civi turned on, and have a contribution page. For the text/longtext fields there is a translation icon next to th...I might be misunderstanding how this is supposed to work, but here's the situation that I'm seeing. I have multilingual for civi turned on, and have a contribution page. For the text/longtext fields there is a translation icon next to the field label in the admin when configuring the page. But when I enable the "allow on behalf of" option, the "on behalf of label" does not have this translation option showing (see screenshot). So it seems that we're not able to provide the right text to the end user in this case.
In addition, when displaying the translated page the following Drupal error shows:
> Notice: Undefined index: for_organization in CRM_Contribute_Form_ContributionBase->buildComponentForm() (line 976 of /home/mysite/public_html/sites/all/modules/civicrm/CRM/Contribute/Form/ContributionBase.php).
Running civicrm 5.12.4 on drupal 7.66 with php 5.6 (I know, I know). Issue was also seen previously on civi 4.7.31.
[civi_trans_issue_1](/uploads/a300619c6ab7cbcabb43e521f7bd46ed/civi_trans_issue_1.jpg)https://lab.civicrm.org/dev/translation/-/issues/25Unselecting from 'Available languages' doesn't drop respective locale views f...2021-08-12T19:25:28ZMonish DebUnselecting from 'Available languages' doesn't drop respective locale views from DBSteps to replicate the issue:
1. Add more than one language from 'Add Language' list say English and French(Canada)
2. Then change civi instance to multilingual
3. DB creates views with locale suffix en_US and fr_CA
4. Now unselect Frenc...Steps to replicate the issue:
1. Add more than one language from 'Add Language' list say English and French(Canada)
2. Then change civi instance to multilingual
3. DB creates views with locale suffix en_US and fr_CA
4. Now unselect French(Canada) and save
Bug: This doesn't drop the fr_CA views from DB as it is not required.https://lab.civicrm.org/dev/translation/-/issues/67Canonize API for storing translated data2021-08-12T19:25:30ZtottenCanonize API for storing translated data# Goal
Enable richer user experiences which incorporate data-translation. Specifically, provide a CRUD API for administrative applications that need to read/write alternate versions of a string in the database.
# Background
* This is ...# Goal
Enable richer user experiences which incorporate data-translation. Specifically, provide a CRUD API for administrative applications that need to read/write alternate versions of a string in the database.
# Background
* This is most immediately motivated by https://lab.civicrm.org/dev/mail/-/issues/83, which aims to improve the process+experience of drafting+testing workflow templates. For this case, the string that is being edited (ie `civicrm_msg_template.msg_html`) is a relatively rich piece of content (with HTML tags, tokens, Smarty expressions - which in turn may vary based on the context for which the template will be used). The richness of the text implies that one should have more features available (token-pickers, syntax-highlighting, ad nauseum). Editing a translation of this content in a generic textbox (as with multilingual UI, Transifex UI, or POEdit) would be difficult and error-prone.
* This is intended as a step in support of https://lab.civicrm.org/community/feature-request/-/issues/26, which is a broad effort (initiated by @ayduns @BjoernE) to re-conceive how the multilingual subsystem works. TLDR: Current multilingual requires significant MySQL schema manipulation. This works for 1-3 languages but does not scale to 10 languages. Resolving it requires changes in the storage/lifecycle of translated data.
* Inspired by this discussion, Eileen wrote a proof-of-concept extension https://github.com/eileenmcnaughton/civi-data-translate. The scope of `civi-data-translate` mostly matches the scope of this filing, but not quite perfectly. It matches insofar as it introduces an APIv4 interface and a MySQL table for strings. It diverges insofar as it specifically touches on `MessageTemplate`. (The work for `MessageTemplate` is left as a separate matter.) Its biggest obstacle is dependency-hell: it requires a skilled administrator to maintain a deployment, which disincentivizes development and usage.
# Approaches
Working within the limits of available code and capacity, it appears feasible to adapt `civi-data-translate` to this purpose. Either:
1. Move its APIv4 interface and data-storage to core-proper, or...
2. Move its APIv4 interface and data-storage to core-extension.
# Comments
* Having an API to edit the strings would be meaningless if we did not have a data-store.
* There is a performance question about using MySQL for a string table. (Most FOSS applications use `gettext` MO files which are optimized for fast lookup of static strings. This is how Civi handles translation of its numerous app-strings.) In prior discussions with @BjoernE @ayduns etal, we identified this balance:
* There is a difference between *administration* (browsing/editing strings) and *runtime lookup* (substituting 1000 strings during a page-load).
* For administration, there is no question about whether the performance of a MySQL string-table would be acceptable. It would be. In fact, many different tools/workflows/stores can be acceptable.
* The performance question is relevant to *runtime lookup of heavily used strings*. The performance question is not necessarily closed, and it depends on other variables (*the #data-strings, the use-case, the hardware, etc*).
* If one does need to optimize lookup, the best known approach is to compile to gettext. To wit: Read strings from whatever source is handy, aggregate them, and [write them](https://github.com/pear/File_Gettext/blob/master/File/Gettext/MO.php) to a cache folder in `*.mo` format. (You can see [de.systopia.l10nmo](https://github.com/systopia/de.systopia.l10nmo) as a foray into this approach of blending/merging string sources.)
* I was worried about proposing this - specifically, worried that it might conflict with a more optimized dataflow. However, on reflection, I think it is complementary progress. Suppose you wanted to patch `l10nmo` to include a feed of strings provided by web-based administrators. If each web UI stored strings differently, then you'd probably give up. But if they use the same (shared/documented) string API, then it's easier to pull from there.
* (*I mention this as a hypothetical. In practice, some things like dev/mail#83 can be achieved without this level of optimization. The upshot is that we can bite off a chunk of work here on the API/storage side and make some incremental progress.*)https://lab.civicrm.org/dev/translation/-/issues/74ts() - Allow symbolic placeholders2022-01-27T13:24:34Ztottents() - Allow symbolic placeholdersOverview
---------
When writing translatable strings, placeholders must be numeric.
This leads to some quirky strings - eg if you're outputting a title and subtitle ("Some Chapter: Some Section"), the only way to encode that is `ts('%1...Overview
---------
When writing translatable strings, placeholders must be numeric.
This leads to some quirky strings - eg if you're outputting a title and subtitle ("Some Chapter: Some Section"), the only way to encode that is `ts('%1: %2')`. This string should be translatable because the layout is language dependent (eg LTR/RTL; eg punctuation-preferences), but the exported string will become meaningless when presented in Transifex (or similar). And it may be confused with other/similar strings.
Current behavior
-----------------
The function `ts(string $str, array $params)` accepts the following `$params`:
* Functional params (`count`, `plural`, `context`, `domain`, `escape`, `skip_translation`)
* Substitution params (numeric keys; `0`, `1`, `2`, ...)
As in:
```php
echo ts('Hello, %1!', [
1 => $name,
]);
echo '<li>' . ts('%1: %2', [
1 => $title,
2 => $subtitle,
]) . '</li>';
echo ts('The directory %1 is not writable. Please check your file permissions.', [
'plural' => 'The following directories are not writable: %1. Please check your file permissions.',
'count' => count($notWritableDirs),
1 => implode(', ', $notWritableDirs),
]),
```
```smarty
{ts 1=Bob}Hello %1!{/ts}
<li>{ts 1="Title" 2="Subtitle"}%1: %2{/ts}</li>
```
~~Proposed behavior (draft 1; symbol-prefix)~~
-----------------
Any `$params` which begin with a symbol (`%`, `_`, `{`, `@`, etc) will be used for variable substitution.
The earlier examples remain valid. Additionally, these examples are also valid:
```php
echo ts('Hello, %name!', [
'%name' => $name,
]);
echo '<li>' . ts('%title: %subtitle', [
'%title' => $title,
'%subtitle' => $subtitle],
) . '</li>';
echo ts('The directory %dir is not writable. Please check your file permissions.', [
'plural' => 'The following directories are not writable: %dir. Please check your file permissions.',
'count' => count($notWritableDirs),
'%dir' => implode(', ', $notWritableDirs),
]),
```
```smarty
{ts _NAME_=Bob}Hello _NAME_!{/ts}
<li>{ts _title_="Foo" _subtitle_="Bar"}_title_: _subtitle_{/ts}</li>
```
Proposed behavior (draft 2; capitalization-based)
-----------------
Any `$params` which begin with a capital letter (`[A-Z]`) will be used for variable substitution.
```php
echo ts('Hello, %NAME!', [
'NAME' => $name,
]);
echo '<li>' . ts('%TITLE: %SUBTITLE', [
'TITLE' => $title,
'SUBTITLE' => $subtitle],
) . '</li>';
echo ts('The directory %DIR is not writable. Please check your file permissions.', [
'plural' => 'The following directories are not writable: %DIR. Please check your file permissions.',
'count' => count($notWritableDirs),
'DIR' => implode(', ', $notWritableDirs),
]),
```
```smarty
{ts NAME=Bob}Hello %NAME!{/ts}
<li>{ts TITLE="Foo" SUBTITLE="Bar"}%TITLE: %SUBTITLE{/ts}</li>
```
Comments
---------
Either draft (using symbol-prefix or using uppercase) should avoid conflicts with existing strings+params. (Existing params do not begin with symbols and they are not uppercase.)
A couple factors in choosing a symbol:
* Using `%` is most consistent with current `ts()` style.
* `ts()` is used in multiple programming languages. Each has different compatibility/constraints.
* Pure PHP and pure JS are fairly flexible (`%FOO`, `{{FOO}}`, `_FOO_`, etc)
* Smarty-HTML (`{ts KEY=VALUE}...{/ts}`) is pretty limited. The bottleneck is how it parses the `KEY`.
* Angular-HTML (`{{ts('...')}}`) is in the middle. It's OK for `{{ts('%FOO')}}`, `{{ts('_FOO_')}}`, but I wouldn't count on `{{ts('{{FOO}}')}}`.
* If you want one symbol that works everywhere, `_` is probably it.
* Being flexible about symbol may be good for compatibility in the most contexts.
I suppose that the uppercase approach constrains style a bit, but maybe that's a good thing - ie you get more consistency in how `ts()` looks across environments.
Questions
---------
Are there any constraints in other layers -- eg Transifex, civistrings -- which would prevent this?
As far as I know, the only constraints which require using numeric-keys are baked into `ts()` itself.