Line 15: |
Line 15: |
| |- | | |- |
| | <samp>ID</samp> | | | <samp>ID</samp> |
− | | A unique identifier for your language. This isn't shown in-game. The recommended format is <code><your name>.<mod name></code>, with no spaces or special characters. | + | | A [[Modding:Common data field types#Unique string ID|unique string ID]] for your language. This isn't shown in-game. |
| |- | | |- |
| | <samp>LanguageCode</samp> | | | <samp>LanguageCode</samp> |
Line 63: |
Line 63: |
| | | |
| ===Example=== | | ===Example=== |
− | This Content Patcher pack would add Esperanto to the game. '''You should change <samp>Pathoschild.Esperanto</samp> to your mod's actual ID.''' | + | This Content Patcher pack would add Esperanto to the game. (<code><nowiki>{{ModId}}</nowiki></code> is a token, which will be replaced with your mod ID automatically.) |
| {{#tag:syntaxhighlight| | | {{#tag:syntaxhighlight| |
| { | | { |
− | "Format": "{{Content Patcher version}}", | + | "Format": "{{Content Patcher version}}",<nowiki> |
| "Changes": [ | | "Changes": [ |
| // define language | | // define language |
Line 73: |
Line 73: |
| "Target": "Data/AdditionalLanguages", | | "Target": "Data/AdditionalLanguages", |
| "Entries": { | | "Entries": { |
− | "Pathoschild.Esperanto": { // for technical reasons, you need to specify the ID here *and* in the "ID" field | + | "{{ModId}}_Esperanto": { // for technical reasons, you need to specify the ID here *and* in the "ID" field |
− | "ID": "Pathoschild.Esperanto", | + | "ID": "{{ModId}}_Esperanto", |
| "LanguageCode": "eo", | | "LanguageCode": "eo", |
− | "ButtonTexture": "Mods/Pathoschild.Esperanto/Button", | + | "ButtonTexture": "Mods/{{ModId}}/Button", |
| "UseLatinFont": true, | | "UseLatinFont": true, |
| "TimeFormat": "[HOURS_24_00]:[MINUTES]", | | "TimeFormat": "[HOURS_24_00]:[MINUTES]", |
Line 88: |
Line 88: |
| { | | { |
| "Action": "Load", | | "Action": "Load", |
− | "Target": "Mods/Pathoschild.Esperanto/Button", | + | "Target": "Mods/{{ModId}}/Button", |
| "FromFile": "assets/button.png" | | "FromFile": "assets/button.png" |
| } | | } |
| ] | | ] |
− | }|lang=javascript}} | + | }</nowiki>|lang=javascript}} |
| | | |
| Once the language is defined, you can add translations to the game by patching game assets like usual, and use the language code you specified above. For example: | | Once the language is defined, you can add translations to the game by patching game assets like usual, and use the language code you specified above. For example: |
Line 222: |
Line 222: |
| {{#tag:syntaxhighlight| | | {{#tag:syntaxhighlight| |
| { | | { |
− | "Format": "{{Content Patcher version}}", | + | "Format": "{{Content Patcher version}}",<nowiki> |
| "Changes": [ | | "Changes": [ |
| // define language | | // define language |
Line 229: |
Line 229: |
| "Target": "Data/AdditionalLanguages", | | "Target": "Data/AdditionalLanguages", |
| "Entries": { | | "Entries": { |
− | "Pathoschild.Esperanto": { // for technical reasons, you need to specify the ID here *and* in the "ID" field | + | "{{ModId}}_Esperanto": { // for technical reasons, you need to specify the ID here *and* in the "ID" field |
− | "ID": "Pathoschild.Esperanto", | + | "ID": "{{ModId}}_Esperanto", |
| "LanguageCode": "eo", | | "LanguageCode": "eo", |
− | "ButtonTexture": "Mods/Pathoschild.Esperanto/Button", | + | "ButtonTexture": "Mods/{{ModId}}/Button", |
| "UseLatinFont": false, | | "UseLatinFont": false, |
− | "FontFile": "Fonts/Esperanto", | + | "FontFile": "Fonts/{{ModId}}/Esperanto", |
| "TimeFormat": "[HOURS_24_00]:[MINUTES]", | | "TimeFormat": "[HOURS_24_00]:[MINUTES]", |
| "ClockTimeFormat": "[HOURS_24_00]:[MINUTES]", | | "ClockTimeFormat": "[HOURS_24_00]:[MINUTES]", |
Line 245: |
Line 245: |
| { | | { |
| "Action": "Load", | | "Action": "Load", |
− | "Target": "Mods/Pathoschild.Esperanto/Button", | + | "Target": "Mods/{{ModId}}/Button", |
| "FromFile": "assets/button.png" | | "FromFile": "assets/button.png" |
| } | | } |
Line 252: |
Line 252: |
| { | | { |
| "Action": "Load", | | "Action": "Load", |
− | "Target": "Fonts/Esperanto", | + | "Target": "Fonts/{{ModId}}/Esperanto", |
| "FromFile": "assets/Esperanto.fnt" | | "FromFile": "assets/Esperanto.fnt" |
| }, | | }, |
| { | | { |
| "Action": "Load", | | "Action": "Load", |
− | "Target": "Fonts/Esperanto_0", | + | "Target": "Fonts/{{ModId}}/Esperanto_0", |
| "FromFile": "assets/Esperanto_0.png" | | "FromFile": "assets/Esperanto_0.png" |
| } | | } |
| ] | | ] |
− | }|lang=javascript}} | + | }</nowiki>|lang=javascript}} |
| + | |
| + | ==Limitations== |
| + | Custom languages must be available very early in the game startup, and won't be handled correctly if they're added later. That means: |
| + | * For Content Patcher packs, they must be added without <samp>When</samp> conditions (or only using immutable conditions like config or <samp>HasMod</samp>). |
| + | * For C# mods, they should be added in [[Modding:Modder Guide/APIs/Events#Game loop|<samp>GameLaunched</samp>]] or earlier. |
| | | |
| ==See also== | | ==See also== |