@quenty/clienttranslator 9.0.0-canary.331.7eefa75.0 → 9.0.0-canary.367.e9fdcbc.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 +125 -1
- package/LICENSE.md +1 -1
- package/package.json +9 -9
- package/src/Client/JSONTranslator.lua +43 -4
- package/src/Client/LocalizationServiceUtils.lua +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,131 @@
|
|
|
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
|
-
# [9.0.0-canary.
|
|
6
|
+
# [9.0.0-canary.367.e9fdcbc.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.21.0...@quenty/clienttranslator@9.0.0-canary.367.e9fdcbc.0) (2023-06-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [8.21.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.20.0...@quenty/clienttranslator@8.21.0) (2023-05-26)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* Fix localization warnings ([3e98cd7](https://github.com/Quenty/NevermoreEngine/commit/3e98cd7135a0d174b4a6f1059b6a2f9fc03b9d6f))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [8.20.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.19.0...@quenty/clienttranslator@8.20.0) (2023-05-08)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [8.19.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.18.1...@quenty/clienttranslator@8.19.0) (2023-04-10)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [8.18.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.18.0...@quenty/clienttranslator@8.18.1) (2023-04-07)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# [8.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.17.0...@quenty/clienttranslator@8.18.0) (2023-04-06)
|
|
50
|
+
|
|
51
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# [8.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.16.0...@quenty/clienttranslator@8.17.0) (2023-04-03)
|
|
58
|
+
|
|
59
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# [8.16.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.15.0...@quenty/clienttranslator@8.16.0) (2023-03-31)
|
|
66
|
+
|
|
67
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# [8.15.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.14.1...@quenty/clienttranslator@8.15.0) (2023-03-31)
|
|
74
|
+
|
|
75
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## [8.14.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.14.0...@quenty/clienttranslator@8.14.1) (2023-03-28)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### Bug Fixes
|
|
85
|
+
|
|
86
|
+
* Localization changes on localeId change ([551ce0b](https://github.com/Quenty/NevermoreEngine/commit/551ce0bb8a99f165529ec33d2130f4b65c01d8e8))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# [8.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.13.1...@quenty/clienttranslator@8.14.0) (2023-03-28)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### Features
|
|
96
|
+
|
|
97
|
+
* Add JSONTranslator:SetEntryValue(translationKey, source, context, localeId, text) ([3790994](https://github.com/Quenty/NevermoreEngine/commit/3790994ec62aceb475b7cddf7b2c30166dc27f96))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
## [8.13.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.13.0...@quenty/clienttranslator@8.13.1) (2023-03-08)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
### Bug Fixes
|
|
107
|
+
|
|
108
|
+
* Fix localization not swapping in soft shutdown if locale swaps ([ee93043](https://github.com/Quenty/NevermoreEngine/commit/ee93043b7da1511f6b86ce33040b422eb9cd6216))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# [8.13.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.12.0...@quenty/clienttranslator@8.13.0) (2023-03-06)
|
|
115
|
+
|
|
116
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# [8.12.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.11.0...@quenty/clienttranslator@8.12.0) (2023-03-05)
|
|
123
|
+
|
|
124
|
+
**Note:** Version bump only for package @quenty/clienttranslator
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# [8.11.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@8.10.0...@quenty/clienttranslator@8.11.0) (2023-02-27)
|
|
7
131
|
|
|
8
132
|
**Note:** Version bump only for package @quenty/clienttranslator
|
|
9
133
|
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/clienttranslator",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.367.e9fdcbc.0",
|
|
4
4
|
"description": "Gets local translator for player",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/blend": "7.0.0-canary.
|
|
29
|
-
"@quenty/instanceutils": "
|
|
30
|
-
"@quenty/loader": "6.1
|
|
31
|
-
"@quenty/maid": "2.
|
|
32
|
-
"@quenty/promise": "
|
|
33
|
-
"@quenty/pseudolocalize": "
|
|
34
|
-
"@quenty/rx": "
|
|
28
|
+
"@quenty/blend": "7.0.0-canary.367.e9fdcbc.0",
|
|
29
|
+
"@quenty/instanceutils": "7.14.0",
|
|
30
|
+
"@quenty/loader": "6.2.1",
|
|
31
|
+
"@quenty/maid": "2.5.0",
|
|
32
|
+
"@quenty/promise": "6.5.0",
|
|
33
|
+
"@quenty/pseudolocalize": "3.2.0",
|
|
34
|
+
"@quenty/rx": "7.11.0",
|
|
35
35
|
"@quenty/table": "3.2.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "e9fdcbc6ea1d46e068bf42a08b833099e9005259"
|
|
41
41
|
}
|
|
@@ -44,6 +44,13 @@ JSONTranslator.__index = JSONTranslator
|
|
|
44
44
|
})
|
|
45
45
|
|
|
46
46
|
print(translator:FormatByKey("actions.respawn"), { playerName = "Quenty"}) --> Respawn Quenty
|
|
47
|
+
|
|
48
|
+
-- Observing is preferred
|
|
49
|
+
maid:GiveTask(translator:ObserveFormatByKey("actions.respawn", {
|
|
50
|
+
playerName = RxInstanceUtils.observeProperty(player, "DisplayName");
|
|
51
|
+
}):Subscribe(function(text)
|
|
52
|
+
print(text) --> "Respawn Quenty"
|
|
53
|
+
end)
|
|
47
54
|
```
|
|
48
55
|
|
|
49
56
|
```lua
|
|
@@ -92,6 +99,33 @@ function JSONTranslator:ObserveLocaleId()
|
|
|
92
99
|
})
|
|
93
100
|
end
|
|
94
101
|
|
|
102
|
+
--[=[
|
|
103
|
+
Adds an entry value to the localization table itself. This can be useful
|
|
104
|
+
for ensuring pseudo localization and/or generating localization values
|
|
105
|
+
from the game data itself.
|
|
106
|
+
|
|
107
|
+
@param translationKey string
|
|
108
|
+
@param source string
|
|
109
|
+
@param context string
|
|
110
|
+
@param localeId string
|
|
111
|
+
@param text string
|
|
112
|
+
]=]
|
|
113
|
+
function JSONTranslator:SetEntryValue(translationKey, source, context, localeId, text)
|
|
114
|
+
assert(type(translationKey) == "string", "Bad translationKey")
|
|
115
|
+
assert(type(source) == "string", "Bad source")
|
|
116
|
+
assert(type(context) == "string", "Bad context")
|
|
117
|
+
assert(type(localeId) == "string", "Bad localeId")
|
|
118
|
+
assert(type(text) == "string", "Bad text")
|
|
119
|
+
|
|
120
|
+
self._localizationTable:SetEntryValue(translationKey, source, context, localeId, text or source)
|
|
121
|
+
|
|
122
|
+
if RunService:IsStudio() then
|
|
123
|
+
self._localizationTable:SetEntryValue(translationKey, source, context,
|
|
124
|
+
PseudoLocalize.getDefaultPseudoLocaleId(),
|
|
125
|
+
PseudoLocalize.pseudoLocalize(text))
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
95
129
|
--[=[
|
|
96
130
|
Gets the current localeId of the translator if it's initialized, or a default if it is not.
|
|
97
131
|
|
|
@@ -184,13 +218,18 @@ function JSONTranslator:ObserveFormatByKey(key, argData)
|
|
|
184
218
|
return Observable.new(function(sub)
|
|
185
219
|
local maid = Maid.new()
|
|
186
220
|
|
|
187
|
-
maid:GivePromise(self._promiseTranslator:Then(function()
|
|
221
|
+
maid:GivePromise(self._promiseTranslator:Then(function(translator)
|
|
188
222
|
if argObservable then
|
|
189
|
-
maid:GiveTask(
|
|
190
|
-
|
|
223
|
+
maid:GiveTask(Rx.combineLatest({
|
|
224
|
+
localeId = RxInstanceUtils.observeProperty(translator, "LocaleId");
|
|
225
|
+
args = argObservable;
|
|
226
|
+
}):Subscribe(function(state)
|
|
227
|
+
sub:Fire(self:FormatByKey(key, state.args))
|
|
191
228
|
end))
|
|
192
229
|
else
|
|
193
|
-
|
|
230
|
+
maid:GiveTask(RxInstanceUtils.observeProperty(translator, "LocaleId"):Subscribe(function()
|
|
231
|
+
sub:Fire(self:FormatByKey(key, nil))
|
|
232
|
+
end))
|
|
194
233
|
end
|
|
195
234
|
end))
|
|
196
235
|
|
|
@@ -40,17 +40,20 @@ function LocalizationServiceUtils.promiseTranslator(player)
|
|
|
40
40
|
timeout = 0.5
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
local rejectedCauseOfTimeout = false
|
|
43
44
|
task.delay(timeout, function()
|
|
44
45
|
if not asyncTranslatorPromise:IsPending() then
|
|
45
46
|
return
|
|
46
47
|
end
|
|
48
|
+
|
|
49
|
+
rejectedCauseOfTimeout = true
|
|
47
50
|
asyncTranslatorPromise:Reject(
|
|
48
51
|
("GetTranslatorForPlayerAsync is still pending after %f, using local table")
|
|
49
52
|
:format(timeout))
|
|
50
53
|
end)
|
|
51
54
|
|
|
52
55
|
return asyncTranslatorPromise:Catch(function(err)
|
|
53
|
-
if err ~= ERROR_PUBLISH_REQUIRED then
|
|
56
|
+
if err ~= ERROR_PUBLISH_REQUIRED and not rejectedCauseOfTimeout then
|
|
54
57
|
warn(("[LocalizationServiceUtils.promiseTranslator] - %s"):format(tostring(err)))
|
|
55
58
|
end
|
|
56
59
|
|