Skip to content

Commit e44be53

Browse files
Locale: Minor changes and bug fixes
1 parent d2ab347 commit e44be53

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

docs/Fakemon/Locale.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Locale
2-
The Locale extension allows developers to manualy register translations for text rather than using an external server like the Translate extension. It is designed for those who want control over the translations.
2+
Locale allows developers to manually register translations of text and get information about languages. It was designed to simplify the process of including manually-curated translations in projects and mitigate the need for automatic translations such as those provided by the Translate extension.
33

44
> [!NOTE]
5-
> Some of these blocks use JSON, a format for storing data in key-value pairs. The JSON extension will make these blocks much easier to use, especially for beginners.
5+
> Many of these blocks use JSON, a format for storing data in key-value pairs. The JSON extension will make these blocks much easier to use, especially for beginners.
66
77

88
## Working With Translation Information
@@ -34,7 +34,7 @@ If you need to merge the existing the existing information with something new, u
3434
```scratchblocks
3535
merge current translation information with JSON [{}] ::#2a5fa0
3636
```
37-
This block takes the current translation information and sets the values of the keys defined in the input to their new values. This can both replace and add new keys.
37+
This block uses the newly-provided JSON to update the existing global translation information by keeping the information that only exists in the original object and adding the new object's values from there. Keys from both objects will use the new values.
3838

3939
You can get the global information with this block:
4040
```scratchblocks

extensions/Fakemon/Locale.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
// Name: Locale
22
// ID: fakemonLocale
3-
// Description: Blocks for manually registering translations of text.
3+
// Description: Blocks for manual translations and language information.
44
// By: Scratch_Fakemon <https://scratch.mit.edu/users/Scratch_Fakemon/>
55
// License: MPL-2.0
66

77
/* Note for contributors:
8-
When updating this extension's block info, make sure to also update the documentation (/docs/Fakemon/Locale.md).
9-
This is most important for adding new blocks, but should also be done for changing block text to avoid confusion.
10-
11-
Additionally, do NOT remove the TypeScript comments (//@ts-ignore); it doesn't like my code :(
8+
When updating this extension's block info, please also update the documentation (/docs/Fakemon/Locale.md). Thanks!
129
*/
1310

1411
(async function (Scratch) {
@@ -31,7 +28,7 @@ Additionally, do NOT remove the TypeScript comments (//@ts-ignore); it doesn't l
3128
*/
3229
let languageNameAndCodeLookupTableGLOBALIZED;
3330
// This is a backup of the lookup table in case the user is offline. It may not always be up-to-date.
34-
// TODO: use a build script to automatically get the latest version of the table to put in here (and maybe also make a version of Locale without this hefty object)
31+
// TODO: use a build script to automatically get the latest version of the table to put in here (and maybe also make a version of Locale without this hefty chonker)
3532
const backupTable = {
3633
menuMap: {
3734
am: [
@@ -15659,7 +15656,7 @@ Additionally, do NOT remove the TypeScript comments (//@ts-ignore); it doesn't l
1565915656
arguments: {
1566015657
JSON: {
1566115658
type: Scratch.ArgumentType.STRING,
15662-
defaultValue: `{"en":{${Scratch.translate("Hello, world!")}:"Hello, world!"},"es":{${Scratch.translate("Hello, world!")}:"¡Hola, mundo!"}}`,
15659+
defaultValue: `{"en":{"${Scratch.translate("Hello, world!")}":"Hello, world!"},"es":{"${Scratch.translate("Hello, world!")}":"¡Hola, mundo!"}}`,
1566315660
},
1566415661
},
1566515662
},
@@ -15673,7 +15670,7 @@ Additionally, do NOT remove the TypeScript comments (//@ts-ignore); it doesn't l
1567315670
arguments: {
1567415671
JSON: {
1567515672
type: Scratch.ArgumentType.STRING,
15676-
defaultValue: `{"en":{${Scratch.translate("Hello, world!")}:"Hello, world!"},"es":{${Scratch.translate("Hello, world!")}:"¡Hola, mundo!"}}`,
15673+
defaultValue: `{"pl":{"${Scratch.translate("Hello, world!")}":"Cześć, świat!"}}`,
1567715674
},
1567815675
},
1567915676
},
@@ -15708,7 +15705,7 @@ Additionally, do NOT remove the TypeScript comments (//@ts-ignore); it doesn't l
1570815705
},
1570915706
JSON: {
1571015707
type: Scratch.ArgumentType.STRING,
15711-
defaultValue: `{${Scratch.translate("Hello, world!")}:"¡Hola, mundo!"}`,
15708+
defaultValue: `{"${Scratch.translate("Hello, world!")}":"¡Hola, mundo!"}`,
1571215709
},
1571315710
},
1571415711
},
@@ -15726,7 +15723,7 @@ Additionally, do NOT remove the TypeScript comments (//@ts-ignore); it doesn't l
1572615723
},
1572715724
JSON: {
1572815725
type: Scratch.ArgumentType.STRING,
15729-
defaultValue: `{${Scratch.translate("Hello, world!")}:"¡Hola, mundo!"}`,
15726+
defaultValue: `{"${Scratch.translate("Apples and bananas")}":"Manzanas y plátanos"}`,
1573015727
},
1573115728
},
1573215729
},
@@ -15933,7 +15930,7 @@ Additionally, do NOT remove the TypeScript comments (//@ts-ignore); it doesn't l
1593315930
Scratch.translate(
1593415931
`This button will ${showRecreatableBlocks ? "hide" : "show"} blocks that can be recreated with other extensions or require values set by these blocks.`
1593515932
)
15936-
); // Explain what the button does
15933+
);
1593715934
if (
1593815935
confirm(
1593915936
Scratch.translate(
@@ -15997,7 +15994,10 @@ Additionally, do NOT remove the TypeScript comments (//@ts-ignore); it doesn't l
1599715994
mergePerLangLocaleJSON(args) {
1599815995
let backupLocaleObject = localeObject; // Save a backup in case something breaks
1599915996
try {
16000-
localeObject[args.LANG] = { ...localeObject, ...JSON.parse(args.JSON) };
15997+
localeObject[args.LANG] = {
15998+
...localeObject[args.LANG],
15999+
...JSON.parse(args.JSON),
16000+
};
1600116001
} catch {
1600216002
localeObject = backupLocaleObject;
1600316003
}

0 commit comments

Comments
 (0)