Skip to content

Commit 9814cd2

Browse files
authored
Merge pull request #5581 from almchung/fes-ko-en
FES ko new translation file + en file minor updates
2 parents ea0fa1d + fd1685e commit 9814cd2

File tree

10 files changed

+147
-59
lines changed

10 files changed

+147
-59
lines changed

src/core/friendly_errors/fes_core.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
208208
p5._friendlyAutoplayError = function(src) {
209209
const message = translator('fes.autoplay', {
210210
src,
211-
link: 'https://developer.mozilla.org/docs/Web/Media/Autoplay_guide'
211+
url: 'https://developer.mozilla.org/docs/Web/Media/Autoplay_guide'
212212
});
213213
console.log(translator('fes.pre', { message }));
214214
};
@@ -760,13 +760,10 @@ if (typeof IS_MINIFIED !== 'undefined') {
760760

761761
// if the flow gets this far, this is likely not a misspelling
762762
// of a p5 property/function
763-
let url1 = 'https://p5js.org/examples/data-variable-scope.html';
764-
let url2 =
765-
'https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/Not_Defined#What_went_wrong';
763+
let url = 'https://p5js.org/examples/data-variable-scope.html';
766764
p5._friendlyError(
767765
translator('fes.globalErrors.reference.notDefined', {
768-
url1,
769-
url2,
766+
url,
770767
symbol: errSym,
771768
location: locationObj
772769
? translator('fes.location', locationObj)
@@ -842,14 +839,13 @@ if (typeof IS_MINIFIED !== 'undefined') {
842839
//let a = null;
843840
//console.log(a.property); -> a is null
844841
let errSym = matchedError.match[1];
845-
let url1 =
842+
let url =
846843
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_property#what_went_wrong';
847-
let url2 =
848-
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null';
844+
/*let url2 =
845+
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null';*/
849846
p5._friendlyError(
850847
translator('fes.globalErrors.type.readFromNull', {
851-
url1,
852-
url2,
848+
url,
853849
symbol: errSym,
854850
location: locationObj
855851
? translator('fes.location', locationObj)
@@ -865,14 +861,13 @@ if (typeof IS_MINIFIED !== 'undefined') {
865861
//let a; -> default value of a is undefined
866862
//console.log(a.property); -> a is undefined
867863
let errSym = matchedError.match[1];
868-
let url1 =
864+
let url =
869865
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_property#what_went_wrong';
870-
let url2 =
871-
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined#description';
866+
/*let url2 =
867+
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined#description';*/
872868
p5._friendlyError(
873869
translator('fes.globalErrors.type.readFromUndefined', {
874-
url1,
875-
url2,
870+
url,
876871
symbol: errSym,
877872
location: locationObj
878873
? translator('fes.location', locationObj)
@@ -1063,7 +1058,7 @@ const helpForMisusedAtTopLevelCode = (e, log) => {
10631058
translator('fes.misusedTopLevel', {
10641059
symbolName,
10651060
symbolType: symbol.type,
1066-
link: FAQ_URL
1061+
url: FAQ_URL
10671062
})
10681063
);
10691064
}

src/core/friendly_errors/file_errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
1212
const fileLoadErrorCases = (num, filePath) => {
1313
const suggestion = translator('fes.fileLoadError.suggestion', {
1414
filePath,
15-
link: 'https://github.com/processing/p5.js/wiki/Local-server'
15+
url: 'https://github.com/processing/p5.js/wiki/Local-server'
1616
});
1717
switch (num) {
1818
case 0:

src/core/friendly_errors/sketch_reader.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ if (typeof IS_MINIFIED !== 'undefined') {
100100
undefined
101101
) {
102102
//if a p5.js function is used ie it is in the funcs array
103+
let url = `https://p5js.org/reference/#/p5/${variableArray[i]}`;
103104
p5._friendlyError(
104105
translator('fes.sketchReaderErrors.reservedFunc', {
106+
url: url,
105107
symbol: variableArray[i]
106108
})
107109
);
@@ -330,8 +332,10 @@ if (typeof IS_MINIFIED !== 'undefined') {
330332
p5Constructors[keyArray[k]].prototype[functionArray[i]] !==
331333
element
332334
) {
335+
let url = `https://p5js.org/reference/#/p5/${functionArray[i]}`;
333336
p5._friendlyError(
334337
translator('fes.sketchReaderErrors.reservedFunc', {
338+
url: url,
335339
symbol: functionArray[i]
336340
})
337341
);

src/core/friendly_errors/validate_params.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
558558
context: (errorObj.position + 1).toString(),
559559
defaultValue: (errorObj.position + 1).toString()
560560
}),
561-
link: '[https://p5js.org/examples/data-variable-scope.html]'
561+
url: 'https://p5js.org/examples/data-variable-scope.html'
562562
};
563563

564564
break;
@@ -652,7 +652,7 @@ if (typeof IS_MINIFIED !== 'undefined') {
652652
// i18next-extract-mark-context-next-line ["EMPTY_VAR", "TOO_MANY_ARGUMENTS", "TOO_FEW_ARGUMENTS", "WRONG_TYPE"]
653653
message = translator('fes.friendlyParamError.type', translationObj);
654654

655-
p5._friendlyError(`${message}.`, func, 3);
655+
p5._friendlyError(`${message}`, func, 3);
656656
}
657657
};
658658

test/unit/core/error_helpers.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,12 +812,12 @@ suite('Global Error Handling', function() {
812812
assert.strictEqual(log.length, 2);
813813
let temp = log[1].split('\n');
814814
temp = temp.filter(e => e.trim().length > 0);
815-
assert.strictEqual(temp.length, 2);
815+
assert.strictEqual(temp.length, 4);
816816
assert.match(log[0], /"asdfg" is not defined/);
817-
assert.match(temp[0], /Error at/);
818-
assert.match(temp[0], /myfun/);
819-
assert.match(temp[1], /Called from/);
820-
assert.match(temp[1], /setup/);
817+
assert.match(temp[1], /Error at/);
818+
assert.match(temp[1], /myfun/);
819+
assert.match(temp[3], /Called from/);
820+
assert.match(temp[3], /setup/);
821821
});
822822
});
823823

translations/dev.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
export { default as en_translation } from './en/translation';
22
export { default as es_translation } from './es/translation';
3+
export { default as ko_translation } from './ko/translation';
34

4-
/**
5+
/**
56
* When adding a new language, add a new "export" statement above this.
67
* For example, if we were to add fr ( French ), we would write:
78
* export { default as fr_translation } from './fr/translation';
89
*
910
* If the language key has a hypen (-), replace it with an underscore ( _ )
1011
* e.g. for es-MX we would write:
1112
* export { default as es_MX_translation } from './es-MX/translation';
12-
*
13+
*
1314
* "es_MX" is the language key whereas "translation" is the filename
1415
* ( translation.json ) or the namespace
1516
*/

translations/en/translation.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"fes": {
3-
"autoplay": "The media that tried to play (with '{{src}}') wasn't allowed to by this browser, most likely due to the browser's autoplay policy. Check out {{link}} for more information about why.",
4-
"checkUserDefinedFns": "It seems that you may have accidentally written {{name}} instead of {{actualName}}.\n\nPlease correct it if it's not intentional.",
3+
"autoplay": "The media that tried to play (with '{{src}}') wasn't allowed to by this browser, most likely due to the browser's autoplay policy.\n\n+ More info: {{url}}",
4+
"checkUserDefinedFns": "It seems that you may have accidentally written {{name}} instead of {{actualName}}. Please correct it if it's not intentional.",
55
"fileLoadError": {
66
"bytes": "It looks like there was a problem loading your file. {{suggestion}}",
77
"font": "It looks like there was a problem loading your font. {{suggestion}}",
@@ -10,43 +10,43 @@
1010
"json": "It looks like there was a problem loading your JSON file. {{suggestion}}",
1111
"large": "If your large file isn't fetched successfully, we recommend splitting the file into smaller segments and fetching those.",
1212
"strings": "It looks like there was a problem loading your text file. {{suggestion}}",
13-
"suggestion": "Try checking if the file path ({{filePath}}) is correct, hosting the file online, or running a local server. (More info at {{link}})",
13+
"suggestion": "Try checking if the file path ({{filePath}}) is correct, hosting the file online, or running a local server.\n\n+ More info: {{url}}",
1414
"table": "It looks like there was a problem loading your table file. {{suggestion}}",
1515
"xml": "It looks like there was a problem loading your XML file. {{suggestion}}"
1616
},
1717
"friendlyParamError": {
18-
"type_EMPTY_VAR": "{{func}}() was expecting {{formatType}} for the {{position}} parameter, received an empty variable instead. {{location}}\n\nIf not intentional, this is often a problem with scope: {{link}}",
19-
"type_TOO_FEW_ARGUMENTS": "{{func}}() was expecting at least {{minParams}} arguments, but received only {{argCount}}. {{location}}",
20-
"type_TOO_MANY_ARGUMENTS": "{{func}}() was expecting no more than {{maxParams}} arguments, but received {{argCount}}. {{location}}",
21-
"type_WRONG_TYPE": "{{func}}() was expecting {{formatType}} for the {{position}} parameter, received {{argType}} instead. {{location}}"
18+
"type_EMPTY_VAR": "{{location}} {{func}}() was expecting {{formatType}} for the {{position}} parameter, received an empty variable instead. If not intentional, this is often a problem with scope.\n\n+ More info: {{url}}",
19+
"type_TOO_FEW_ARGUMENTS": "{{location}} {{func}}() was expecting at least {{minParams}} arguments, but received only {{argCount}}.",
20+
"type_TOO_MANY_ARGUMENTS": "{{location}} {{func}}() was expecting no more than {{maxParams}} arguments, but received {{argCount}}.",
21+
"type_WRONG_TYPE": "{{location}} {{func}}() was expecting {{formatType}} for the {{position}} parameter, received {{argType}} instead."
2222
},
2323
"globalErrors": {
2424
"reference": {
25-
"cannotAccess": "\nError ▶️ \"{{symbol}}\" is used before declaration. Make sure you have declared the variable before using it.\n\n{{location}}\n\nFor more: {{url}}",
26-
"notDefined": "\nError ▶️ \"{{symbol}}\" is not defined in the current scope {{location}}.\n\nIf you have defined it in your code, you should check its scope, spelling, and letter-casing (JavaScript is case-sensitive). For more:\n{{url1}}\n{{url2}}"
25+
"cannotAccess": "\n{{location}} \"{{symbol}}\" is used before declaration. Make sure you have declared the variable before using it.\n\n+ More info: {{url}}",
26+
"notDefined": "\n{{location}} \"{{symbol}}\" is not defined in the current scope. If you have defined it in your code, you should check its scope, spelling, and letter-casing (JavaScript is case-sensitive).\n\n+ More info: {{url}}"
2727
},
28-
"stackSubseq": "▶️ Called from line {{line}} in \"{{func}}\" in {{file}} ({{location}})\n\n",
29-
"stackTop": "▶️ Error at line {{line}} in \"{{func}}\" in {{file}} ({{location}})\n\n",
28+
"stackSubseq": "└[{{location}}] \n\t Called from line {{line}} in {{func}}()\n",
29+
"stackTop": "┌[{{location}}] \n\t Error at line {{line}} in {{func}}()\n",
3030
"syntax": {
31-
"badReturnOrYield": "\nSyntax Error ▶️ return lies outside of a function. Make sure you’re not missing any brackets, so that return lies inside a function.\nFor more: {{url}}",
32-
"invalidToken": "\nSyntax Error ▶️ Found a symbol that JavaScript doesn't recognize or didn't expect at it's place.\nFor more: {{url}}",
33-
"missingInitializer": "\nSyntax Error ▶️ A const variable is declared but not initialized. In JavaScript, an initializer for a const is required. A value must be specified in the same statement in which the variable is declared. Check the line number in the error and assign the const variable a value.\nFor more: {{url}}",
34-
"redeclaredVariable": "\nSyntax Error ▶️ \"{{symbol}}\" is being redeclared. JavaScript doesn't allow declaring a variable more than once. Check the line number in error for redeclaration of the variable.\nFor more: {{url}}",
35-
"unexpectedToken": "\nSyntax Error ▶️ Symbol present at a place that wasn't expected.\nUsually this is due to a typo. Check the line number in the error for anything missing/extra.\nFor more: {{url}}"
31+
"badReturnOrYield": "\nSyntax Error - return lies outside of a function. Make sure you’re not missing any brackets, so that return lies inside a function.\n\n+ More info: {{url}}",
32+
"invalidToken": "\nSyntax Error - Found a symbol that JavaScript doesn't recognize or didn't expect at it's place.\n\n+ More info: {{url}}",
33+
"missingInitializer": "\nSyntax Error - A const variable is declared but not initialized. In JavaScript, an initializer for a const is required. A value must be specified in the same statement in which the variable is declared. Check the line number in the error and assign the const variable a value.\n\n+ More info: {{url}}",
34+
"redeclaredVariable": "\nSyntax Error - \"{{symbol}}\" is being redeclared. JavaScript doesn't allow declaring a variable more than once. Check the line number in error for redeclaration of the variable.\n\n+ More info: {{url}}",
35+
"unexpectedToken": "\nSyntax Error - Symbol present at a place that wasn't expected.\nUsually this is due to a typo. Check the line number in the error for anything missing/extra.\n\n+ More info: {{url}}"
3636
},
3737
"type": {
38-
"constAssign": "\nError ▶️ A const variable is being re-assigned. In javascript, re-assigning a value to a constant is not allowed. If you want to re-assign new values to a variable, make sure it is declared as var or let.\n{{location}}\nFor more: {{url}}",
39-
"notfunc": "\nError ▶️ \"{{symbol}}\" could not be called as a function {{location}}.\nCheck the spelling, letter-casing (JavaScript is case-sensitive) and its type.\nFor more: {{url}}",
40-
"notfuncObj": "\nError ▶️ \"{{symbol}}\" could not be called as a function {{location}}.\nVerify whether \"{{obj}}\" has \"{{symbol}}\" in it and check the spelling, letter-casing (JavaScript is case-sensitive) and its type.\nFor more: {{url}}",
41-
"readFromNull": "\nError ▶️ The property of null can't be read. In javascript the value null indicates that an object has no value.\nFor more: \n{{url1}}\n{{url2}}",
42-
"readFromUndefined": "\nError ▶️ Cannot read property of undefined. Check the line number in error and make sure the variable which is being operated is not undefined.\nFor more: \n{{url1}}\n{{url2}}"
38+
"constAssign": "\n{{location}} A const variable is being re-assigned. In javascript, re-assigning a value to a constant is not allowed. If you want to re-assign new values to a variable, make sure it is declared as var or let.\n\n+ More info: {{url}}",
39+
"notfunc": "\n{{location}} \"{{symbol}}\" could not be called as a function.\nCheck the spelling, letter-casing (JavaScript is case-sensitive) and its type.\n\n+ More info: {{url}}",
40+
"notfuncObj": "\n{{location}} \"{{symbol}}\" could not be called as a function.\nVerify whether \"{{obj}}\" has \"{{symbol}}\" in it and check the spelling, letter-casing (JavaScript is case-sensitive) and its type.\n\n+ More info: {{url}}",
41+
"readFromNull": "\n{{location}} The property of null can't be read. In javascript the value null indicates that an object has no value.\n\n+ More info: {{url}}",
42+
"readFromUndefined": "\n{{location}} Cannot read property of undefined. Check the line number in error and make sure the variable which is being operated is not undefined.\n\n + More info: {{url}}"
4343
}
4444
},
45-
"libraryError": "An error with message \"{{error}}\" occurred inside the p5js library when {{func}} was called {{location}}\n\nIf not stated otherwise, it might be an issue with the arguments passed to {{func}}.",
46-
"location": "(on line {{line}} in {{file}} [{{location}}])",
47-
"misspelling": "It seems that you may have accidentally written \"{{name}}\" instead of \"{{actualName}}\" {{location}}.\n\nPlease correct it to {{actualName}} if you wish to use the {{type}} from p5.js",
48-
"misspelling_plural": "It seems that you may have accidentally written \"{{name}}\" {{location}}.\n\nYou may have meant one of the following:\n{{suggestions}}",
49-
"misusedTopLevel": "Did you just try to use p5.js's {{symbolName}} {{symbolType}}? If so, you may want to move it into your sketch's setup() function.\n\nFor more details, see: {{link}}",
45+
"libraryError": "{{location}} An error with message \"{{error}}\" occurred inside the p5js library when {{func}} was called. If not stated otherwise, it might be an issue with the arguments passed to {{func}}.",
46+
"location": "[{{file}}, line {{line}}]",
47+
"misspelling": "{{location}} It seems that you may have accidentally written \"{{name}}\" instead of \"{{actualName}}\". Please correct it to {{actualName}} if you wish to use the {{type}} from p5.js.",
48+
"misspelling_plural": "{{location}} It seems that you may have accidentally written \"{{name}}\".\nYou may have meant one of the following: \n{{suggestions}}",
49+
"misusedTopLevel": "Did you just try to use p5.js's {{symbolName}} {{symbolType}}? If so, you may want to move it into your sketch's setup() function.\n\n+ More info: {{url}}",
5050
"positions": {
5151
"p_1": "first",
5252
"p_10": "tenth",
@@ -63,10 +63,10 @@
6363
},
6464
"pre": "\n🌸 p5.js says: {{message}}",
6565
"sketchReaderErrors": {
66-
"reservedConst": "you have used a p5.js reserved variable \"{{symbol}}\" make sure you change the variable name to something else.\n({{url}})",
67-
"reservedFunc": "you have used a p5.js reserved function \"{{symbol}}\" make sure you change the function name to something else."
66+
"reservedConst": "you have used a p5.js reserved variable \"{{symbol}}\" make sure you change the variable name to something else.\n\n+ More info: {{url}}",
67+
"reservedFunc": "you have used a p5.js reserved function \"{{symbol}}\" make sure you change the function name to something else.\n\n+ More info: {{url}}"
6868
},
6969
"welcome": "Welcome! This is your friendly debugger. To turn me off, switch to using p5.min.js.",
70-
"wrongPreload": "An error with message \"{{error}}\" occurred inside the p5js library when \"{{func}}\" was called {{location}}.\n\nIf not stated otherwise, it might be due to \"{{func}}\" being called from preload. Nothing besides load calls (loadImage, loadJSON, loadFont, loadStrings, etc.) should be inside the preload function."
70+
"wrongPreload": "{{location}} An error with message \"{{error}}\" occurred inside the p5js library when \"{{func}}\" was called. If not stated otherwise, it might be due to \"{{func}}\" being called from preload. Nothing besides load calls (loadImage, loadJSON, loadFont, loadStrings, etc.) should be inside the preload function."
7171
}
7272
}

translations/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import en from './en/translation';
66
/**
77
* Here, we define a default/fallback language which we can use without internet.
88
* You won't have to change this when adding a new language.
9-
*
9+
*
1010
* `translation` is the namespace we are using for our initial set of strings
1111
*/
1212
export default {
@@ -18,10 +18,11 @@ export default {
1818
/**
1919
* This is a list of languages that we have added so far.
2020
* If you have just added a new language (yay!), add its key to the list below
21-
* (`en` is english, `es` es español). Also add its export to
21+
* (`en` is english, `es` es español). Also add its export to
2222
* dev.js, which is another file in this folder.
2323
*/
2424
export const languages = [
2525
'en',
26-
'es'
26+
'es',
27+
'ko'
2728
];

0 commit comments

Comments
 (0)