question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is having different translations for specific parameter values doable?

See original GitHub issue

The problem Currently we have quite a few translatable strings dealing with amounts. For example, Current leader is [civInfo] with [amount] Technologies discovered., +[amount] untradable copies, [amount] Nations, etc. All of these work fine when amounts != 1, but at least in English, 1 Technologies, 1 copies and 1 Nations don’t sound great, at least compared to 1 Nation, etc.

Other languages, such as German, might have noun genders, such as der Arbeiter or die Fregatte. Translating these for uniques such as <for [baseUnitFilter] units> would then necessarily result in choosing either der or die, which would sound weird for words of the other gender. In cases like these it’s also not an option to add der or die to the translation of Worker and Frigate respectively, as they should be in the accusativ form due to the for, making it für den Arbeiter if memory serves me well.

The proposed solution One way to solve both these problems, is to have specific translations for specific parameter values. For example, adding the line [1] Nations = [1] Nation to english.properties to translate that correctly? Similarly, the translation for [Worker] units = für [jeden Arbeiter] einheden (excuse my German) could solve the problem for these languages, be it at the cost of basically the entire benefit that translations parameters give.

At least one challenge at first glance seem to me to keep the translation during regeneration of the translation.

Is this a good solution to this problem, and would someone be willing to code it?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JackRainycommented, May 6, 2022

Also, an idea about genders: what if use an additional braces as a placeholder for affected verbs and nouns. For example: [unit] is destroyed = [unit] {знищений|знищена|знищено} // has 3 genders [unit] is destroyed = [unit] est {détruit|détruite} // has 2 genders [unit] is destroyed = [unit] er ødelagt // has 1 gender or all of them are equal While the units will have their own flag Cannon = Пушка {2} or Cannon = le canon {1}.

0reactions
J0anJosepcommented, May 29, 2022

I would like to explain how it is dealt with in other projects I have worked on and allow translators to provide good localisation. I know maybe it is too complicated for the project.

Granary[num] = [def=m]graner[num | 0:s | 1: | 2:s]    // Setting the gender of this string and its variants: 0 graners, 1 graner, 2 or more graners
Cathedral[num] = [def=f]catedral[num | 0:s | 1: | 2:s]    // Setting the gender of this string and its variants

The [number] [construction] is being built = [number + construction:def | 1m:El | 1f:La | 2m:Els | 2f:Les] [number | 1: | 2:number] [construction, number] s'est[number | 1:à | 2:an] construïnt.
// First, the determiner el/la/els/les is chosen depending on [number] and [construction]
// Then [construction, number] adds the name of the construction, possibly depending on the number of units being built: cathedral for 1 unit, cathedrals for more than one.

So we can have:

number=1, construction=Granary
(The granary is being built.)
El graner s'està construïnt.


number=5, construction=Granary
(The 5 granaries are being built.)
Els 5 graners s'estan construïnt.

number=1, construction=Cathedral
(The Cathedral is being built.)
La catedral s'està construïnt.

number=2, construction=Cathedral
(The 2 Cathedrals are being built.)
Les 2 catedrals s'estan construïnt.

Of course, once you identify a widely used particle (usually determiners) in other strings that need to be formatted, you can add a new string for easing translations:

The[number, string] = [number + string:def | 1m:El | 1f:La | 2m:Els | 2f:Les]
[insert: The, number, construction] [construction, number] s'est[number | 1:à | 2:an] construïnt.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Translating text fields - ServiceNow Docs
You can translate long pieces of text into the language of the user. ... Identify the FX Currency field and its display parameters....
Read more >
DeepL API - DeepL Translate
Parameter In Type text. required body array source_lang. optional body string target_lang. required body string
Read more >
Translator options - IBM
The command-level language translator has a list of options that you can select from to translate your COBOL, C, C++, PL/I, and Assembler...
Read more >
GNU gettext utilities
Even if the program will eventually make most of its output in the foreign languages, one has to decide whether the input syntax,...
Read more >
Best Practices for XML Internationalization - W3C
If you have different languages in the attribute values and content ... or contextual usage of a particular element, such as what a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found