@quenty/clienttranslator 14.8.0 → 14.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [14.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@14.8.0...@quenty/clienttranslator@14.9.0) (2024-10-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Localization should change whenever entries change ([9d2f0b7](https://github.com/Quenty/NevermoreEngine/commit/9d2f0b7a41d97902520a0adb41bfeab85cce3302))
|
|
12
|
+
* Output parsing was wrong for LocalizationEntryParserUtils ([8de8872](https://github.com/Quenty/NevermoreEngine/commit/8de8872d5ef9c432bc91b581f8534810fd32f0e7))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [14.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@14.7.0...@quenty/clienttranslator@14.8.0) (2024-09-25)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @quenty/clienttranslator
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/clienttranslator",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.9.0",
|
|
4
4
|
"description": "Gets local translator for player",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/blend": "^12.
|
|
29
|
-
"@quenty/instanceutils": "^13.
|
|
30
|
-
"@quenty/loader": "^10.
|
|
31
|
-
"@quenty/maid": "^3.
|
|
32
|
-
"@quenty/promise": "^10.
|
|
33
|
-
"@quenty/promisemaid": "^5.
|
|
28
|
+
"@quenty/blend": "^12.8.0",
|
|
29
|
+
"@quenty/instanceutils": "^13.8.0",
|
|
30
|
+
"@quenty/loader": "^10.6.0",
|
|
31
|
+
"@quenty/maid": "^3.4.0",
|
|
32
|
+
"@quenty/promise": "^10.6.0",
|
|
33
|
+
"@quenty/promisemaid": "^5.6.0",
|
|
34
34
|
"@quenty/pseudolocalize": "^3.4.0",
|
|
35
|
-
"@quenty/rx": "^13.
|
|
35
|
+
"@quenty/rx": "^13.8.0",
|
|
36
36
|
"@quenty/string": "^3.3.0",
|
|
37
37
|
"@quenty/table": "^3.5.0",
|
|
38
|
-
"@quenty/valueobject": "^13.
|
|
38
|
+
"@quenty/valueobject": "^13.8.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "035abfa088c854a73e1c65b350267eaa17669646"
|
|
44
44
|
}
|
|
@@ -82,29 +82,32 @@ function LocalizationEntryParserUtils._parseTableToResultsList(lookupTable, sour
|
|
|
82
82
|
elseif type(text) == "string" then
|
|
83
83
|
local found = lookupTable[key]
|
|
84
84
|
if found then
|
|
85
|
-
found.Values[localeId] =
|
|
85
|
+
found.Values[localeId] = text
|
|
86
86
|
else
|
|
87
|
-
-- Guarantee the context is unique. This is important because Roblox will not
|
|
88
|
-
-- allow something with the same source without a differing context text.
|
|
89
|
-
local context = string.format("Generated from %s with key %s", tableName, key)
|
|
90
|
-
|
|
91
87
|
found = {
|
|
92
|
-
Context = context;
|
|
93
88
|
Example = text;
|
|
94
89
|
Key = key;
|
|
95
|
-
|
|
90
|
+
Context = string.format("[TEMP] - Generated from %s with key %s", tableName, key);
|
|
91
|
+
Source = text; -- Tempt!
|
|
96
92
|
Values = {
|
|
97
93
|
[localeId] = text;
|
|
98
94
|
};
|
|
99
95
|
};
|
|
100
96
|
|
|
101
|
-
if RunService:IsStudio() and sourceLocaleId == localeId then
|
|
102
|
-
found.Values[PseudoLocalize.getDefaultPseudoLocaleId()] = PseudoLocalize.pseudoLocalize(text)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
97
|
lookupTable[key] = found;
|
|
106
98
|
end
|
|
107
99
|
|
|
100
|
+
-- Ensure assignment
|
|
101
|
+
if sourceLocaleId == localeId then
|
|
102
|
+
-- Guarantee the context is unique. This is important because Roblox will not
|
|
103
|
+
-- allow something with the same source without a differing context text.
|
|
104
|
+
found.Context = string.format("Generated from %s with key %s", tableName, key)
|
|
105
|
+
found.Source = text
|
|
106
|
+
|
|
107
|
+
if RunService:IsStudio() then
|
|
108
|
+
found.Values[PseudoLocalize.getDefaultPseudoLocaleId()] = PseudoLocalize.pseudoLocalize(text)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
108
111
|
else
|
|
109
112
|
error(string.format("Bad type for text at key '%s'", key))
|
|
110
113
|
end
|
|
@@ -100,12 +100,13 @@ function JSONTranslator:Init(serviceBag)
|
|
|
100
100
|
self._localizationTable:SetEntryExample(item.Key, item.Source, item.Context, item.Example)
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
self._sourceTranslator.Value = self._localizationTable:GetTranslator(localeId)
|
|
105
|
-
end))
|
|
103
|
+
-- TODO: Maybe don't hold these unless needed
|
|
106
104
|
self._maid:GiveTask(self._translatorService:ObserveLocaleId():Subscribe(function(localeId)
|
|
107
105
|
self._localTranslator.Value = self._localizationTable:GetTranslator(localeId)
|
|
108
106
|
end))
|
|
107
|
+
self._maid:GiveTask(RxInstanceUtils.observeProperty(self._localizationTable, "SourceLocaleId"):Subscribe(function(localeId)
|
|
108
|
+
self._sourceTranslator.Value = self._localizationTable:GetTranslator(localeId)
|
|
109
|
+
end))
|
|
109
110
|
end
|
|
110
111
|
|
|
111
112
|
--[=[
|
|
@@ -119,13 +120,17 @@ function JSONTranslator:ObserveFormatByKey(translationKey, translationArgs)
|
|
|
119
120
|
assert(type(translationKey) == "string", "Key must be a string")
|
|
120
121
|
|
|
121
122
|
return Rx.combineLatest({
|
|
122
|
-
|
|
123
|
+
cloudTranslator = self:ObserveTranslator();
|
|
123
124
|
translationKey = translationKey;
|
|
124
125
|
translationArgs = self:_observeArgs(translationArgs);
|
|
125
126
|
}):Pipe({
|
|
126
127
|
Rx.switchMap(function(mainState)
|
|
127
|
-
if mainState.
|
|
128
|
-
return
|
|
128
|
+
if mainState.cloudTranslator then
|
|
129
|
+
return self._translatorService:ObserveLocaleId():Pipe({
|
|
130
|
+
Rx.map(function()
|
|
131
|
+
return self:_doTranslation(mainState.cloudTranslator, mainState.translationKey, mainState.translationArgs)
|
|
132
|
+
end);
|
|
133
|
+
})
|
|
129
134
|
end
|
|
130
135
|
|
|
131
136
|
-- Fall back to local or source translator
|
|
@@ -119,7 +119,13 @@ end
|
|
|
119
119
|
@return Observable<string>
|
|
120
120
|
]=]
|
|
121
121
|
function TranslatorService:ObserveLocaleId()
|
|
122
|
-
|
|
122
|
+
if self._localeIdValue then
|
|
123
|
+
return self._localeIdValue:Observe()
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
self._localeIdValue = self._maid:Add(ValueObject.new("en-us", "string"))
|
|
127
|
+
|
|
128
|
+
self._localeIdValue:Mount(self._translator:Observe():Pipe({
|
|
123
129
|
Rx.switchMap(function(translator)
|
|
124
130
|
if translator then
|
|
125
131
|
return RxInstanceUtils.observeProperty(translator, "LocaleId")
|
|
@@ -137,7 +143,9 @@ function TranslatorService:ObserveLocaleId()
|
|
|
137
143
|
end
|
|
138
144
|
end);
|
|
139
145
|
Rx.distinct();
|
|
140
|
-
})
|
|
146
|
+
}))
|
|
147
|
+
|
|
148
|
+
return self._localeIdValue:Observe()
|
|
141
149
|
end
|
|
142
150
|
|
|
143
151
|
--[=[
|