@quenty/clienttranslator 5.1.1-canary.256.edbbcfc.0 → 6.0.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,7 +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
- ## [5.1.1-canary.256.edbbcfc.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@5.1.0...@quenty/clienttranslator@5.1.1-canary.256.edbbcfc.0) (2022-03-27)
6
+ # [6.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@5.2.0...@quenty/clienttranslator@6.0.0) (2022-05-21)
7
+
8
+
9
+ ### Features
10
+
11
+ * Centralize generated localization tables onto one location. This is useful because it allows exporting just the one csv for localization. ([8dcbaad](https://github.com/Quenty/NevermoreEngine/commit/8dcbaad5f7c0a8d1b0e0f450dfa69033eb8ad35c))
12
+
13
+
14
+
15
+
16
+
17
+ # [5.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/clienttranslator@5.1.0...@quenty/clienttranslator@5.2.0) (2022-03-27)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/clienttranslator
9
20
 
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014-2021 Quenty
3
+ Copyright (c) 2014-2022 Quenty
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/clienttranslator",
3
- "version": "5.1.1-canary.256.edbbcfc.0",
3
+ "version": "6.0.0",
4
4
  "description": "Gets local translator for player",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,15 +25,15 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/blend": "3.1.1-canary.256.edbbcfc.0",
29
- "@quenty/loader": "4.0.1-canary.256.edbbcfc.0",
30
- "@quenty/maid": "2.2.1-canary.256.edbbcfc.0",
31
- "@quenty/promise": "4.1.1-canary.256.edbbcfc.0",
32
- "@quenty/pseudolocalize": "2.0.2-canary.256.edbbcfc.0",
33
- "@quenty/rx": "4.1.1-canary.256.edbbcfc.0"
28
+ "@quenty/blend": "^4.0.0",
29
+ "@quenty/loader": "^5.0.0",
30
+ "@quenty/maid": "^2.3.0",
31
+ "@quenty/promise": "^5.0.0",
32
+ "@quenty/pseudolocalize": "^2.1.0",
33
+ "@quenty/rx": "^5.0.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "edbbcfc38516772a791d50dc43cd6b304ffc4aff"
38
+ "gitHead": "9f7eaea7543c33c89d2e32c38491b13f9271f4f7"
39
39
  }
@@ -5,7 +5,6 @@
5
5
 
6
6
  local require = require(script.Parent.loader).load(script)
7
7
 
8
- local LocalizationService = game:GetService("LocalizationService")
9
8
  local Players = game:GetService("Players")
10
9
  local RunService = game:GetService("RunService")
11
10
 
@@ -52,7 +51,6 @@ function JSONTranslator.new(...)
52
51
  self._fallbacks = {}
53
52
 
54
53
  if RunService:IsRunning() then
55
- self._localizationTable.Parent = LocalizationService
56
54
  self._promiseTranslator = LocalizationServiceUtils.promiseTranslator(Players.LocalPlayer)
57
55
  else
58
56
  self._promiseTranslator = Promise.resolved(self._englishTranslator)
@@ -5,10 +5,14 @@
5
5
  @class JsonToLocalizationTable
6
6
  ]=]
7
7
 
8
+ local LocalizationService = game:GetService("LocalizationService")
8
9
  local HttpService = game:GetService("HttpService")
10
+ local RunService = game:GetService("RunService")
9
11
 
10
12
  local JsonToLocalizationTable = {}
11
13
 
14
+ local LOCALIZATION_TABLE_NAME = "GeneratedJSONTable"
15
+
12
16
  --[[
13
17
  Recursively iterates through the object to construct strings and add it to the localization table
14
18
  @param localeId string -- The localizationid to add
@@ -52,12 +56,28 @@ function JsonToLocalizationTable.localeFromName(name)
52
56
  end
53
57
  end
54
58
 
59
+ function JsonToLocalizationTable.getOrCreateLocalizationTable()
60
+ local localizationTable = LocalizationService:FindFirstChild(LOCALIZATION_TABLE_NAME)
61
+
62
+ if not localizationTable then
63
+ localizationTable = Instance.new("LocalizationTable")
64
+ localizationTable.Name = LOCALIZATION_TABLE_NAME
65
+
66
+ if RunService:IsRunning() then
67
+ localizationTable.Parent = LocalizationService
68
+ end
69
+ end
70
+
71
+ return localizationTable
72
+ end
73
+
55
74
  --[=[
56
75
  Loads a folder into a localization table
57
76
  @param folder Folder -- A Roblox folder with StringValues containing JSON, named with the localization in mind
58
77
  ]=]
59
78
  function JsonToLocalizationTable.loadFolder(folder)
60
- local localizationTable = Instance.new("LocalizationTable")
79
+ local localizationTable = JsonToLocalizationTable.getOrCreateLocalizationTable()
80
+
61
81
  for _, item in pairs(folder:GetDescendants()) do
62
82
  if item:IsA("StringValue") then
63
83
  local localeId = JsonToLocalizationTable.localeFromName(item.Name)
@@ -79,11 +99,10 @@ end
79
99
  function JsonToLocalizationTable.toLocalizationTable(first, second)
80
100
  if typeof(first) == "Instance" then
81
101
  local result = JsonToLocalizationTable.loadFolder(first)
82
- result.Name = ("JSONTable_%s"):format(first.Name)
102
+ -- result.Name = ("JSONTable_%s"):format(first.Name)
83
103
  return result
84
104
  elseif type(first) == "string" and type(second) == "table" then
85
105
  local result = JsonToLocalizationTable.loadTable(first, second)
86
- result.Name = "JSONTable"
87
106
  return result
88
107
  else
89
108
  error("Bad args")
@@ -97,8 +116,10 @@ end
97
116
  @return LocalizationTable
98
117
  ]=]
99
118
  function JsonToLocalizationTable.loadTable(localeId, dataTable)
100
- local localizationTable = Instance.new("LocalizationTable")
119
+ local localizationTable = JsonToLocalizationTable.getOrCreateLocalizationTable()
120
+
101
121
  recurseAdd(localizationTable, localeId, "", dataTable)
122
+
102
123
  return localizationTable
103
124
  end
104
125