@quenty/clienttranslator 4.1.2 → 4.3.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,28 @@
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
+ # [4.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@4.2.0...@quenty/clienttranslator@4.3.0) (2021-12-09)
7
+
8
+
9
+ ### Features
10
+
11
+ * JSONTranslator can take a table instead of a Roblox instance too ([af92033](https://github.com/Quenty/NevermoreEngine/commit/af920336f3a66e16757659779d559b8b660c603c))
12
+
13
+
14
+
15
+
16
+
17
+ # [4.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@4.1.2...@quenty/clienttranslator@4.2.0) (2021-11-20)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * Support MacOS syncing ([#225](https://github.com/Quenty/NevermoreEngine/issues/225)) ([03f9183](https://github.com/Quenty/NevermoreEngine/commit/03f918392c6a5bdd33f8a17c38de371d1e06c67a))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [4.1.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@4.1.1...@quenty/clienttranslator@4.1.2) (2021-10-30)
7
29
 
8
30
  **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": "4.1.2",
3
+ "version": "4.3.0",
4
4
  "description": "Gets local translator for player",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,11 +26,11 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@quenty/loader": "^3.1.1",
29
- "@quenty/promise": "^3.1.2",
29
+ "@quenty/promise": "^3.2.0",
30
30
  "@quenty/pseudolocalize": "^2.0.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "e9cd4223c7fda7c852db9743ef844baa19cacb13"
35
+ "gitHead": "adc1a4962fffcccc7f55411ebed6c9306d86dac6"
36
36
  }
@@ -17,15 +17,11 @@ local JSONTranslator = {}
17
17
  JSONTranslator.ClassName = "JSONTranslator"
18
18
  JSONTranslator.__index = JSONTranslator
19
19
 
20
- function JSONTranslator.new(parent)
20
+ function JSONTranslator.new(...)
21
21
  local self = setmetatable({}, JSONTranslator)
22
22
 
23
- self._parent = assert(parent, "No parent")
24
-
25
23
  -- Cache localizaiton table, because it can take 10-20ms to load.
26
- self._localizationTable = JsonToLocalizationTable.loadFolder(self._parent)
27
- self._localizationTable.Name = ("JSONTable_%s"):format(parent.Name)
28
-
24
+ self._localizationTable = JsonToLocalizationTable.toLocalizationTable(...)
29
25
  self._englishTranslator = self._localizationTable:GetTranslator("en")
30
26
  self._fallbacks = {}
31
27
 
@@ -61,6 +61,26 @@ function JsonToLocalizationTable.loadFolder(folder)
61
61
  return localizationTable
62
62
  end
63
63
 
64
+ function JsonToLocalizationTable.toLocalizationTable(first, second)
65
+ if typeof(first) == "Instance" then
66
+ local result = JsonToLocalizationTable.loadFolder(first)
67
+ result.Name = ("JSONTable_%s"):format(first.Name)
68
+ return result
69
+ elseif type(first) == "string" and type(second) == "table" then
70
+ local result = JsonToLocalizationTable.loadTable(first, second)
71
+ result.Name = "JSONTable"
72
+ return result
73
+ else
74
+ error("Bad args")
75
+ end
76
+ end
77
+
78
+ function JsonToLocalizationTable.loadTable(localeId, dataTable)
79
+ local localizationTable = Instance.new("LocalizationTable")
80
+ recurseAdd(localizationTable, localeId, "", dataTable)
81
+ return localizationTable
82
+ end
83
+
64
84
  --- Adds json to a localization table
65
85
  -- @param localizationTable The localization table to add to
66
86
  -- @param localeId The localeId to use
@@ -2,6 +2,6 @@
2
2
  "name": "node_modules",
3
3
  "globIgnorePaths": [ "**/.package-lock.json" ],
4
4
  "tree": {
5
- "$path": { "optional": "..\\node_modules" }
5
+ "$path": { "optional": "../node_modules" }
6
6
  }
7
7
  }