@dydxprotocol/v4-localization 0.0.6

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.
Files changed (68) hide show
  1. package/.github/workflows/publish.yml +38 -0
  2. package/.gitleaks.toml +17 -0
  3. package/.gitleaksignore +0 -0
  4. package/.nvmrc +1 -0
  5. package/config/countries.json +1117 -0
  6. package/config/localization/app.ts +23 -0
  7. package/config/localization/de/app.json +1316 -0
  8. package/config/localization/de/tooltips.json +228 -0
  9. package/config/localization/en/app.json +1316 -0
  10. package/config/localization/en/tooltips.json +228 -0
  11. package/config/localization/es/app.json +1311 -0
  12. package/config/localization/es/tooltips.json +228 -0
  13. package/config/localization/fr/app.json +1311 -0
  14. package/config/localization/fr/tooltips.json +228 -0
  15. package/config/localization/ja/app.json +1311 -0
  16. package/config/localization/ja/tooltips.json +228 -0
  17. package/config/localization/ko/app.json +1316 -0
  18. package/config/localization/ko/tooltips.json +228 -0
  19. package/config/localization/languages.json +43 -0
  20. package/config/localization/pt/app.json +1311 -0
  21. package/config/localization/pt/tooltips.json +228 -0
  22. package/config/localization/ru/app.json +1316 -0
  23. package/config/localization/ru/tooltips.json +228 -0
  24. package/config/localization/tooltip.ts +23 -0
  25. package/config/localization/tr/app.json +1311 -0
  26. package/config/localization/tr/tooltips.json +228 -0
  27. package/config/localization/zh-CN/app.json +1124 -0
  28. package/config/localization/zh-CN/tooltips.json +228 -0
  29. package/config/localization_notifications/de/app.json +40 -0
  30. package/config/localization_notifications/en/app.json +40 -0
  31. package/config/localization_notifications/es/app.json +40 -0
  32. package/config/localization_notifications/fr/app.json +40 -0
  33. package/config/localization_notifications/index.ts +23 -0
  34. package/config/localization_notifications/ja/app.json +40 -0
  35. package/config/localization_notifications/ko/app.json +40 -0
  36. package/config/localization_notifications/pt/app.json +40 -0
  37. package/config/localization_notifications/ru/app.json +40 -0
  38. package/config/localization_notifications/tr/app.json +40 -0
  39. package/config/localization_notifications/zh-CN/app.json +40 -0
  40. package/config/localizations_native/de/app.json +451 -0
  41. package/config/localizations_native/en/app.json +451 -0
  42. package/config/localizations_native/es/app.json +451 -0
  43. package/config/localizations_native/fr/app.json +451 -0
  44. package/config/localizations_native/index.ts +23 -0
  45. package/config/localizations_native/ja/app.json +451 -0
  46. package/config/localizations_native/ko/app.json +451 -0
  47. package/config/localizations_native/pt/app.json +451 -0
  48. package/config/localizations_native/ru/app.json +451 -0
  49. package/config/localizations_native/tr/app.json +451 -0
  50. package/config/localizations_native/zh-CN/app.json +398 -0
  51. package/config/markets.json +700 -0
  52. package/config/prod/walletsV2.json +646 -0
  53. package/config/staging/walletsV2.json +646 -0
  54. package/config/version_ios.json +14 -0
  55. package/index.ts +25 -0
  56. package/package.json +22 -0
  57. package/readme.md +63 -0
  58. package/scripts/codegen_localization_app +0 -0
  59. package/scripts/codegen_localization_app.swift +59 -0
  60. package/scripts/codegen_localization_tooltips.swift +46 -0
  61. package/scripts/generated/app.ts +1356 -0
  62. package/scripts/generated/tooltips.ts +134 -0
  63. package/scripts/merge_jsons.sh +48 -0
  64. package/scripts/publish-if-not-exists.sh +21 -0
  65. package/v4/staging/markets.json +704 -0
  66. package/wallet_connect/dapps.json +4836 -0
  67. package/wallet_connect/index.ts +7 -0
  68. package/wallet_connect/wallets.json +4033 -0
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@dydxprotocol/v4-localization",
3
+ "version": "0.0.6",
4
+ "description": "v4 localization",
5
+ "main": "index.ts",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/dydxprotocol/v4-localization.git"
12
+ },
13
+ "author": "",
14
+ "license": "ISC",
15
+ "bugs": {
16
+ "url": "https://github.com/dydxprotocol/v4-localization/issues"
17
+ },
18
+ "homepage": "https://github.com/dydxprotocol/v4-localization#readme",
19
+ "devDependencies": {
20
+ "@types/node": "^20.1.7"
21
+ }
22
+ }
package/readme.md ADDED
@@ -0,0 +1,63 @@
1
+ # Translation structures
2
+
3
+ There are four folders for translations.
4
+
5
+ /config/localization
6
+ /config/localization_notifications
7
+ /config/localizations_native
8
+ /marketing
9
+
10
+ Each of them contains a list of language folders, such as
11
+ /en (English)
12
+ /es (Spanish)
13
+ /fr (French)
14
+ /ja (Japanese)
15
+ /ko (Korean)
16
+ /pt (Portugal)
17
+ /ru (Russian)
18
+ /tr (Turkey)
19
+ /zh-CN (Simplified Chinese)
20
+
21
+ Each folder contains either a list of JSON files ending .json, or text files ending .txt
22
+
23
+ # Work with Github
24
+
25
+ The "main" branch cannot be written directly. You must create a separate branch, make the changes there, commit and push the branch, and then create a PR (Push request) to "main"
26
+
27
+ For your branch, recommend to use "/changes/{language-code}-{date}" as the branch name.
28
+
29
+ For example, if you are working on Spanish, and started the work on July 13th, 2022, use the branch name "/changes/es-2022-07-13".
30
+
31
+ Once your PR is accepted and merged into "main", the branch is removed from the repo. Create a new branch for next batch of changes.
32
+
33
+ # JSON Translations
34
+
35
+ Please translate each JSON entry, using the file in /en folder as the original, and translate into the same file name in other language files.
36
+
37
+ For example, there is a /config/localization/en/app.json file. It should be translated into Spanish in /config/localization/es/app.json file.
38
+
39
+ The key should stay the same. The value should be translated. For example
40
+ "YOUR_POSITION_WAS_LIQUIDATED": "Your position was liquidated." is translated to Spanish as
41
+ "YOUR_POSITION_WAS_LIQUIDATED": "Tu posición ha sido liquidada."
42
+
43
+ You will see curly brackets in some cases. Keep the text in the curly brackets as is. For example
44
+ "LEAGUES_LAUNCH_BODY": "Climb the rankings ladder to earn your share of the {PRIZE}." is translated to Spanish as
45
+ "LEAGUES_LAUNCH_BODY": "Asciende en la clasificación para ganar tu parte del {PRIZE}.",
46
+
47
+ "{PRIZE}" should not be translated.
48
+
49
+ Make sure the JSON format is still valid. Recommend to use https://jsonformatter.curiousconcept.com to validate the translated JSON
50
+
51
+ # TXT Translations
52
+
53
+ Text files can be translated as a single unit.
54
+
55
+ # Generating app.ts
56
+ '''
57
+ ./codegen_localization_app.swift ../config/localization/en/app.json > ./generated/app.ts
58
+ '''
59
+
60
+ # Generating tooltips.ts
61
+ '''
62
+ ./codegen_localization_tooltips.swift ../config/localization/en/tooltips.json > ./generated/tooltips.ts
63
+ '''
Binary file
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env swift
2
+
3
+ import Foundation
4
+
5
+ // This script is used to generate the TS constants for the app.json file
6
+
7
+ if CommandLine.arguments.count < 2 {
8
+ print("Usage: codegen_localization_app.swift <path to app.json>")
9
+ exit(1)
10
+ }
11
+
12
+ let appJsonPath = CommandLine.arguments[1]
13
+ var keys: Set<String> = []
14
+
15
+ guard let appJsonData = FileManager.default.contents(atPath: appJsonPath) else {
16
+ print("Could not read app.json file at path \(appJsonPath)")
17
+ exit(1)
18
+ }
19
+
20
+ guard let appJson = try? JSONSerialization.jsonObject(with: appJsonData, options: []) as? [String: Any] else {
21
+ print("Could not parse app.json file at path \(appJsonPath)")
22
+ exit(1)
23
+ }
24
+
25
+ print("// !! GENERATED FILE - DO NOT EDIT\n")
26
+ print("// Generated from \(appJsonPath) using \(CommandLine.arguments[0])\n")
27
+
28
+ for key in appJson.keys.sorted() {
29
+ print("export const \(key)_STRING_KEYS = {")
30
+ generateItems(keyPath: key, lastKey: nil, value: appJson[key])
31
+ print("};\n")
32
+ }
33
+
34
+ func generateItems(keyPath: String, lastKey: String?, value: Any?) {
35
+ let digits = CharacterSet.decimalDigits
36
+
37
+ if let value = value as? [String: Any] {
38
+ if let lastKey = lastKey {
39
+ print("\n // \(lastKey)\n")
40
+ }
41
+ for subKey in value.keys.sorted() {
42
+ generateItems(keyPath: keyPath + "." + subKey, lastKey: subKey, value: value[subKey])
43
+ }
44
+ } else if let lastKey = lastKey {
45
+ // ensure no duplicate keys
46
+ if (keys.contains(lastKey)) {
47
+ return
48
+ }
49
+
50
+ keys.insert(lastKey)
51
+
52
+ // add single quotes to keys that start with a number
53
+ if let range = lastKey.rangeOfCharacter(from: digits), range.lowerBound == lastKey.startIndex {
54
+ print(" \'\(lastKey)\': \'\(keyPath)\',")
55
+ } else {
56
+ print(" \(lastKey): \'\(keyPath)\',")
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env swift
2
+
3
+ import Foundation
4
+
5
+ // This script is used to generate the TS constants for the tooltips.json file
6
+
7
+ if CommandLine.arguments.count < 2 {
8
+ print("Usage: codegen_localization_app.swift <path to tooltips.json>")
9
+ exit(1)
10
+ }
11
+
12
+ let appJsonPath = CommandLine.arguments[1]
13
+
14
+ guard let appJsonData = FileManager.default.contents(atPath: appJsonPath) else {
15
+ print("Could not read tooltips.json file at path \(appJsonPath)")
16
+ exit(1)
17
+ }
18
+
19
+ guard let appJson = try? JSONSerialization.jsonObject(with: appJsonData, options: []) as? [String: Any] else {
20
+ print("Could not parse tooltips.json file at path \(appJsonPath)")
21
+ exit(1)
22
+ }
23
+
24
+ print("// !! GENERATED FILE - DO NOT EDIT\n")
25
+ print("// Generated from \(appJsonPath) using \(CommandLine.arguments[1])\n")
26
+
27
+ print("export const TOOLTIP_STRING_KEYS = {")
28
+ generateItems(keyPath: "TOOLTIPS", lastKey: nil, value: appJson)
29
+ print("};\n")
30
+
31
+
32
+ func generateItems(keyPath: String, lastKey: String?, value: Any?) {
33
+ if let value = value as? [String: Any] {
34
+ if let lastKey = lastKey, value.keys.contains("TITLE"), value.keys.contains("BODY") {
35
+ print(" \(lastKey)_BODY: \'\(keyPath).BODY\',")
36
+ print(" \(lastKey)_TITLE: \'\(keyPath).TITLE\',")
37
+ } else {
38
+ if let lastKey = lastKey {
39
+ print("\n // \(lastKey)\n")
40
+ }
41
+ for subKey in value.keys.sorted() {
42
+ generateItems(keyPath: keyPath + "." + subKey, lastKey: subKey, value: value[subKey])
43
+ }
44
+ }
45
+ }
46
+ }