Localization Tutorial (Civ5)

From Civilization Modding Wiki
Revision as of 22:57, 5 January 2013 by Merri (talk | contribs) (I hope there are no errors in this first version. And I also hope I have time/interest later on to improve this article.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This small tutorial is an attempt to bring some light into how you can actually use the provided string forms, genders and plurality. It is recommended to read Adding New Language and Localization Syntax first as this tutorial mostly focuses on details not available in the official documentation.

Transforms

:gender

Gender transform allows you to select which text alongside the currently active gender is shown depending on what the gender is.

First here we have some sample data to look at:

<Row Tag="TXT_KEY_SAMPLE">
    <Text>Form 1|Form 2|Form 3|Form 4</Text>
    <Gender>neuter:trait_one|masculine:trait_two|feminine:trait_three|mixed:trait_four</Gender>
</Row>

neuter, masculine, feminine and mixed are hardcoded gender values and must be used. The second part values after : are called traits and you can call them anything you like. They can be left undefined, so you can do something like this as well:

<Row Tag="TXT_KEY_TRAIT_GRACIOUS">
    <Text>Courtois|Courtoise</Text>
    <Gender>masculine|feminine</Gender>
</Row>


A practical French sample:

{1:gender *:vowel?l'; masculine?le ; feminine?la ;}{1}
  • le garçon ("garçon" is masculine)
  • la fille ("fille" is feminine)
  • l'arbre ("arbre" is masculine)
  • l'église ("église" is feminine)

Or against TXT_KEY_SAMPLE:

  • le Form 2
  • la Form 3

Note that at this point the system knows which is the selected gender for {1} and thus the result depends on that. You can find information on how to select a specific gender manually further below in this article.


:plural

Allows you to define a plural form.

<Row Tag="TXT_KEY_HORSE">
    <Text>hevonen|hevosta|hevoset|hevosista</Text>
    <Gender>neuter:nominative|neuter:elative|neuter:nominative|neuter:elative</Gender>
    <Plurality>1|1|2|2</Plurality>
</Row>

The sample above is already a slightly complex case as the basic Finnish form for a "horse" is "hevonen" and "horses" would be "hevoset". However when dealing with numbers Finnish uses elative case when we are telling how many horses we have, which is unlike English.

Plurality with just the number

{1} = any number {2} = TXT_KEY_HORSE

{1:plural 1?Yksi {2}; other?{1} {2 ^ 'neuter:elative'};}

Results:

  • Yksi hevonen (one horse)
  • 2 hevosta (two horses)
  • 3 hevosta (three horses)

Plurality with everything

{1} = any number {2} = TXT_KEY_HORSE

{1:plural 1?Yksi {2}; other?{1} {{2 * {1}} ^ 'neuter:elative'};}

Results:

  • Yksi hevonen (one horse)
  • 2 hevosista (two of the horses)
  • 3 hevosista (three of the horses)


TODO

  • :textkey
  • :upper
  • :lower
  • :title
  • :percent
  • :number
  • :roman
  • :spellout


Forms, gender and plurality

Sample data:

<Row Tag="TXT_KEY_SAMPLE">
    <Text>Form 1|Form 2|Form 3|Form 4</Text>
    <Gender>neuter:trait_one|masculine:trait_two|feminine:trait_three|mixed:trait_four</Gender>
    <Plurality>1|1|1|2</Plurality>
</Row>

In the following examples there must be no lookup @ character with any form, gender or plural selection.

Selecting a form

You can select a specific form by using brackets.

<Text>This is my {1_Sample[2]}</Text>

Result: "This is my Form 2"


Selecting a gender

<Text>This is my {1_Sample ^ 'feminine:trait_three'}</Text>

Result: "This is my Form 3"


Selecting a plural

2_Num = 2

<Text>This is my {1_Sample * 2_Num}</Text>

Result: "This is my Form 4"


Transforms with forms, gender or plural

You cannot mix a form, gender or plural selector with a transform. Transform always applies to the first form available. If there is a solution to this problem it is unknown.