(engine: VisualNovelEngine)
| 40 | } |
| 41 | |
| 42 | export function localize (engine: VisualNovelEngine): void { |
| 43 | engine.trigger ('willLocalize'); |
| 44 | |
| 45 | // Setup the correct locale for the dates |
| 46 | const language = engine.preference ('Language') as string; |
| 47 | |
| 48 | const langMetadata = engine._languageMetadata[language]; |
| 49 | |
| 50 | if (langMetadata?.code) { |
| 51 | Settings.defaultLocale = langMetadata.code; |
| 52 | } |
| 53 | |
| 54 | engine.element ().find ('[data-string]').each ((element) => { |
| 55 | const stringKey = $_(element).data ('string'); |
| 56 | |
| 57 | if (stringKey) { |
| 58 | const string_translation = translateString (engine, stringKey); |
| 59 | |
| 60 | // Check if the translation actually exists and is not empty before |
| 61 | // replacing the text. |
| 62 | if (typeof string_translation !== 'undefined' && string_translation !== '') { |
| 63 | $_(element).text (string_translation); |
| 64 | } |
| 65 | } |
| 66 | }); |
| 67 | |
| 68 | engine.trigger ('didLocalize'); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * This method will try to translate parts of a string |
nothing calls this directly
no test coverage detected