-
Notifications
You must be signed in to change notification settings - Fork 12
/
ModLocalizationProvider.reds
86 lines (75 loc) · 2.66 KB
/
ModLocalizationProvider.reds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// -----------------------------------------------------------------------------
// Codeware.Localization.ModLocalizationProvider
// -----------------------------------------------------------------------------
//
// Purpose:
// - Resolve packages by language code
// - Define logic on locale and gender changes
//
// Supported language codes:
// - pl-pl (Polish)
// - en-us (English)
// - es-es (Spanish)
// - fr-fr (French)
// - it-it (Italian)
// - de-de (German)
// - es-mx (Latin American Spanish)
// - kr-kr (Korean)
// - zh-cn (Simplified Chinese)
// - ru-ru (Russian)
// - pt-br (Brazilian Portuguese)
// - jp-jp (Japanese)
// - zh-tw (Traditional Chinese)
// - ar-ar (Arabic)
// - cz-cz (Czech)
// - hu-hu (Hungarian)
// - tr-tr (Turkish)
// - th-th (Thai)
//
// -----------------------------------------------------------------------------
//
// public abstract class ModLocalizationProvider extends ScriptableSystem {
// public func GetPackage(language: CName) -> ref<ModLocalizationPackage>
// public func GetFallback() -> CName
// public func OnLocaleChange()
// public func OnGenderChange()
// }
//
module Codeware.Localization
public abstract class ModLocalizationProvider extends ScriptableSystem {
protected func OnAttach() {
GameInstance.GetScriptableSystemsContainer(this.GetGameInstance())
.QueueRequest(RegisterProviderRequest.Create(this));
}
public func GetPackage(language: CName) -> ref<ModLocalizationPackage>
public func GetFallback() -> CName
public func OnLocaleChange()
public func OnGenderChange()
public func GetOnScreenEntries(language: CName, out entries: array<localizationPersistenceOnScreenEntry>) {
let packages: array<ref<ModLocalizationPackage>>;
let fallback = this.GetFallback();
if NotEquals(language, fallback) {
let fallbackPackage = this.GetPackage(fallback);
if IsDefined(fallbackPackage) {
ArrayPush(packages, fallbackPackage);
}
}
let mainPackage = this.GetPackage(language);
if IsDefined(mainPackage) {
ArrayPush(packages, mainPackage);
}
for package in packages {
let values: array<wref<IScriptable>>;
package.GetEntries(EntryType.Interface).GetValues(values);
for value in values {
let entry = value as LocalizationEntry;
ArrayPush(entries, new localizationPersistenceOnScreenEntry(
0ul,
entry.GetKey(),
entry.GetVariant(PlayerGender.Female),
entry.GetVariant(PlayerGender.Male)
));
}
}
}
}