Translating talk:Cita
Major message key and variable renaming
Hi @Nike and Abijeet Patro!
In an upcoming version of our software we have been required to change to Mozilla's Fluent for i18n and l10n. Instead of .properties
files which we were using so far, Fluent uses .ftl
files which in the context of our project differ in the following two main aspects:
Named variables:
We were using a combination of %s
, %d
, %1$s
, %2$s
, %1$d
, %2$d
, etc for our variables. But Fluent requires named variables instead, such as {$namedVariable}
, {$1}
, etc.
Message key names:
We were using dots (.
) in our message keys to express an idea of "levels" or "nesting". For example, message.key.level
, message.key.level.sub-level
, etc. However, Fluent doesn't seem to support dots in message key names.
So our questions would be:
- Do you support outputting to
.ftl
files directly?
- Do you support named variables? Alternatively, I guess we could just convert things like
$1%s
in the Translatewiki output into{$1%s}
during our build process. In this case we would still need to replace instances of generic%s
into$1%s
,$2%s
, etc as needed.
- What would be your recommended procedure to change message key names (e.g.,
message.key.level.sub-level
tomessage-key-level-sub_level
) and variables names (e.g.,%s
to$1%s
-or{$1}
if supported)?
Thank you for your support, as always! Diegodlh (talk) 13:30, 19 July 2024 (UTC)
- Thanks for the message.
- > Do you support outputting to
.ftl
files directly? - At this moment no but I think it would be good to have support for this format. Created: https://phabricator.wikimedia.org/T370840. I'm not sure when this will get done though.
- > Do you support named variables? Alternatively, I guess we could just convert things like
$1%s
in the Translatewiki output into{$1%s}
during our build process. In this case we would still need to replace instances of generic%s
into$1%s
,$2%s
, etc as needed. - Yes, it should be possible to add support for named variables.
- > What would be your recommended procedure to change message key names (e.g.,
message.key.level.sub-level
tomessage-key-level-sub_level
) and variables names (e.g.,%s
to$1%s
-or{$1}
if supported)? - We'd have to split the rename and variable name changes across two different imports. First do the rename of message keys, import it into translatewiki.net and then do the variables name changes. The system should identify and import the message key renames. Imports happen at minute 30 past every 2nd hour. We can coordinate to make this happen.
- Thanks and regards, Abijeet Patro (talk) 05:02, 24 July 2024 (UTC)
- Thanks for your reply, @Abijeet Patro!
- > First do the rename of message keys, import it into translatewiki.net and then do the variables name changes.
- What do you mean by importing them into translatewiki.net? Is it OK if I push the changes to the main branch of the Github repository? Is that what you mean by "importing"?
- On the other hand, to save a step in our upcoming build process, can we change the path where the translations are stored? What should we do to do this?
- Thank you!! Diegodlh (talk) 23:08, 30 July 2024 (UTC)
- Oh! And... do I have to make the message key renaming in all the files (I can easily do that)? Or do you prefer that we do it in the base English file only? Diegodlh (talk) 23:10, 30 July 2024 (UTC)
- Yes you are right about "import". Make the renames in base English file only, and then push the changes to the main branch of GitHub repo. Translatewiki will pull those changes in, and will identify that keys have been renamed.
- Once that is done, you can make changes to the variables. In the meantime, I'll configure the system to validate for the new format of the variables.
- Hope that clears things up!
- Regards, Abijeet Patro (talk) 10:29, 1 August 2024 (UTC)
- I created: https://phabricator.wikimedia.org/T371587 to track this work.
- Regards, Abijeet Patro (talk) 10:36, 1 August 2024 (UTC)
- Thank you very much @Abijeet Patro!
- We realized that, because we are currently using translation files coming from Translatewiki both in the previous (not using Fluent) and in the current (using Fluent) versions of Cita, it would be better that we make as few changes as possible to the translation files seen by Translatewiki, and have them adapted for Fluent automatically during build by us.
- This means we won't be changing message key ids and we won't use named variables in the end, at least for now. I will add a comment to the task you created about this.
- I have just made some small variable name changes though. I guess they will be picked up by Translatewiki soon.
- Thank you! Diegodlh (talk) 20:09, 15 August 2024 (UTC)
- Dear @Abijeet Patro, I see the changes have been picked up by Translatewiki. See for example here: the variable names have been changed from %s to %1$s and %2$s respectively as expected, on the base English version. I assumed the variable names would be updated automatically on all languages, but apparently they haven't. As per your previous message ("make the renames in base English file only") I made the variable rename in English only. Should I go ahead and make it in all other languages? Thank you! Diegodlh (talk) 16:10, 16 August 2024 (UTC)
- The variables names won't be automatically updated, but the translations will be marked as outdated and over time translators will go through and update them. But since this might cause runtime issues, please go ahead and update them. Abijeet Patro (talk) 01:39, 17 August 2024 (UTC)
- Dear @Abijeet Patro, I see the changes have been picked up by Translatewiki. See for example here: the variable names have been changed from %s to %1$s and %2$s respectively as expected, on the base English version. I assumed the variable names would be updated automatically on all languages, but apparently they haven't. As per your previous message ("make the renames in base English file only") I made the variable rename in English only. Should I go ahead and make it in all other languages? Thank you! Diegodlh (talk) 16:10, 16 August 2024 (UTC)
%1$s and similar variables in Persian (fa) language
Hi @Nike and Abijeet Patro! I was about to merge the latest pull request we got from translatewiki (here) but I noticed something weird in the message added to the Persian (fa) translations. This is a message that includes %1$s
and %2$s
variables.
I thought that it could have been a mistake by the translatewiki contributor, so I tried to fix it myself at the translatewiki site (here).
However, here I noticed that whenever I clicked on one of the %1$s
or %2$s
variables below, they would be introduced as s$1%
or s$2%
!
How do we fix this? Diegodlh (talk) 01:33, 10 September 2024 (UTC)
- Hi @Diegodlh, I'm able to reproduce the issue. Some additional notes, if the variable is inserted in a newline, it works as expected, but inserting it in-between the rtl text, makes it rtl as well.
- I've created this bug report to handle this: https://phabricator.wikimedia.org/T374415
- Regards, Abijeet Patro (talk) 07:05, 10 September 2024 (UTC)
- Hi @Diegodlh
- I spoke to @Nike about this, and we think this is mostly a unicode rendering feature (issue?). Our validators don't find an issue with the strings. If the variables were missing or incorrect, our validators would complain. Additionally, none of the other projects that have variables with rtl translations have had issues.
- Regards, Abijeet Patro (talk) 13:55, 10 September 2024 (UTC)
- Oh wow, interesting! On Github it looks even weirder, see here. But if I search for "%1$s" in the browser, the separate chunks of text ("%1" and "$s") get highlighted. So it definitely looks like a rendering thing. I will go ahead and merge the pull request.
- As for the Phabricator task, I will let you decide what you want to do with it. I guess it is still confusing how it shows in the Translatewiki editor even if behind scenes everything is alright.
- Thank you both for your help! Diegodlh (talk) 16:49, 10 September 2024 (UTC)