-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: relocate i18n files (#706)
delete now empty misc directory
- Loading branch information
Showing
9 changed files
with
183 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,4 @@ backend/cdk.out/ | |
backend/infra.js | ||
|
||
# game data files | ||
misc/i18n/*.json | ||
src/lib/i18n/*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# I18n | ||
|
||
If you come across any issues with the translation setup, just send a message | ||
in [dev-chat](https://discord.com/channels/800607517074784256/1198367043167195246) on the discord server | ||
|
||
### Adding a new language | ||
|
||
When adding a new language | ||
|
||
- create a new locale file in `public/locales` if the appropriate one does not yet exist. | ||
- in `src/lib/i18n/generateTranslations.ts`, modify the `outputLocaleMapping` as necessary so that future gameData | ||
updates are also applied to the newly created locale, and then copy + paste the relevant `gameData.yaml` file into | ||
the newly created locale folder | ||
- in `src/lib/i18n/generateTranslations.ts`, modify `tbNames` to set the proper name for Stelle/Caelus for your locale if | ||
it is not already done. | ||
- add the new language to the list of languages in `src/lib/i18n/i18n.ts` if it does not already exist, and add a flag in | ||
`public/assets/misc/flags`, with the name `[locale].webp`. (all current flags are downloaded | ||
from https://flagpedia.net) | ||
- once the translation has been completed, add the language to the list of completed languages in | ||
`src/lib/i18n/LanguageSelector.tsx`. | ||
|
||
### Adding new text | ||
|
||
When any displayed text is added to the webpage, it should be done directly through the i18n setup. | ||
|
||
- Add the new translation strings in the relevant en yaml file | ||
- if a new file is necessary, make sure to add it to the loaded namespaces in `src/lib/i18n/i18n.ts` | ||
- Send a message in the discord server to notify other translators of the new text. | ||
- Leave the en translation next to the t function in the code as a code comment | ||
`const message = t('Thing.Messages.Success') /*'Operation successful'*/` | ||
- **After modifying the translation files, execute `npm run update-resources` from the root directory.** | ||
|
||
### Updating gameData.yaml | ||
|
||
These files are generated by using the `generateTranslations.ts` file in `src/lib/i18n`. | ||
|
||
Before running the script: | ||
|
||
- Update, if necessary, the beta information in `src/lib/i18n/betaInformation.ts`. | ||
- The english information must include the most recent beta information before running the script, other languages | ||
can also have beta information added to `gameData.yaml` by making a new entry in the `betaInformation` object. | ||
- Outdated content that is now available in game can be removed but will not cause issues if left behind. | ||
- Add the required `.json` files (listed in `requiredFiles.md`) into the `src/lib/i18n` directory, making sure that they | ||
are up to date with the current game version | ||
|
||
Run the script by typing `npm run update-gameData` in the command line from the root directory. | ||
|
||
### Writing EN yaml files | ||
|
||
Guidelines for writing yaml files in EN: | ||
|
||
* Keep keys unquoted | ||
* Keep strings unquoted if possible | ||
* If quotes are needed, use double quotes | ||
* If double quotes would need to be escaped or if the string is excessively long, use a yaml fold `>-` | ||
* If the string contains special characters: e.g. `{` `}` `'` `"` `:` etc, make sure they are quoted or folded | ||
|
||
When working with code, re-use the common namespace where possible. | ||
|
||
**After modifying the translation files, execute `npm run update-resources` from the root directory.** | ||
|
||
### Updating other files | ||
|
||
Updating / writing the translations for languages other than english is done via crowdin. | ||
Reach out on [Discord](https://discord.gg/YHCCaXEhfV) if you wish to help write the translations. | ||
|
||
You will come across some translations that look like the following: | ||
`"valueTextPart1 $t(namespace:key, {options}) valueTextPart2"`, this is used to reference an already existing | ||
translation within a translation string. | ||
In most cases, such a string will be translated as follows: | ||
`"translatedValueTextPart1 $t(namespace:key, {options}) translatedValueTextPart2"` | ||
however there may be some cases where you find it appropriate to modify the inner section as well. | ||
|
||
Certain strings include double braced words | ||
|
||
You will also see some translation strings include double braced words (*Immediately draws 2 jade tile(s) and increases DMG by <u>**{{skillStackDmg}}**</u>% until the end of the current turn. This effect can stack up to 4 time(s).*). | ||
These are used to inject a dynamic value into the translated string (e.g. a varying buff, or a number of relics, etc...). | ||
These should be left as is in the translation, but can be moved around as needed within the sentence. | ||
|
||
Finally, some strings will have tags in them to allow for special formatting (e.g. `codeblocks` or **bold text**). | ||
These strings will looks something like `"<0>someText</0>SomeMoreText"`. | ||
When translating these, the tags surrounding a section of text indicate its formatting. | ||
However, the segments don't need to enclosed within a tag. The example above could, for example, be translated as: | ||
`"textTranslated <0>someTextTranslated</0><1>someMoreTextTranslated</1>"`. | ||
This would allow `someTextTranslated` to have the same formatting as `someText` all while having something else precede it in the sentence. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { InputLocale } from 'lib/i18n/generateTranslations' | ||
|
||
export const betaInformation: betaInformation = { | ||
en: { | ||
Characters: [ | ||
{ | ||
key: 1225, | ||
value: { | ||
Name: 'Fugue', | ||
}, | ||
}, | ||
{ | ||
key: 1313, | ||
value: { | ||
Name: 'Sunday', | ||
}, | ||
}, | ||
], | ||
Lightcones: [ | ||
{ | ||
id: 23034, | ||
value: { | ||
Name: 'A Grounded Ascent', | ||
}, | ||
}, | ||
{ | ||
id: 23035, | ||
value: { | ||
Name: 'Long Road Leads Home', | ||
}, | ||
}, | ||
], | ||
RelicSets: [], | ||
}, | ||
} | ||
|
||
type betaInformation = Partial<Record<InputLocale, { Characters: Character[];Lightcones: LightCone[];RelicSets: RelicSet[] }>> | ||
type Character = { key: number; value: { Name: string } } | ||
type LightCone = { id: number; value: { Name: string } } | ||
type RelicSet = { id: number; value: { Name: string; Description2pc: string; Description4pc?: string } } |
Oops, something went wrong.