Skip to content

Commit

Permalink
Allowing override of product locale to add custom client side transla… (
Browse files Browse the repository at this point in the history
#1501)

* Allowing override of product locale to add custom client side translation

* Allowing override of product locale to add custom client side translation
  • Loading branch information
rismehta committed Jan 15, 2025
1 parent dd544c3 commit 47678c4
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"FileCloseAccessText": "Enter 키를 눌러 파일 삭제",
"FileSizeGreater": "파일 ${0}이(가) 예상 크기 ${1}MB를 초과합니다.",
"FileNameInvalid": "파일 이름이 (.)으로 시작하거나, \\ / : * ? \" < > | ; % $를 포함하거나, nul, prn, con, lpt 또는 com과 같이 예약된 키워드인 파일은 첨부하지 마십시오.",
"FileMimeTypeInvalid": "파일 ${0}은(는) 지원되지 않는 파일 유형입니다.",
"InternalFormSubmissionError": "temp"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,90 @@
{
"FileCloseAccessText" : "กด Enter เพื่อลบไฟล์ ",
"FileSizeGreater" : "ไฟล์ ${0} ใหญ่กว่าขนาดที่คาดไว้: ${1}MB",
"FileNameInvalid" : "ห้ามแนบไฟล์ที่ชื่อไฟล์ขึ้นต้นด้วย (.) มี \\ / : * ? \" < > | ; % $ หรือเป็นคีย์เวิร์ดที่สงวนไว้ เช่น nul, prn, con, lpt หรือ com",
"FileMimeTypeInvalid" : "ไฟล์ ${0} เป็นประเภทไฟล์ที่ไม่รองรับ",
"InternalFormSubmissionError" : "พบข้อผิดพลาดภายในขณะส่งแบบฟอร์ม",
"type" : "กรุณาใส่ค่าที่ถูกต้อง.",
"required" : "กรุณากรอกข้อมูลในช่องนี้.",
"minimum" : "ค่าต้องมากกว่าหรือเท่ากับ ${0}.",
"maximum" : "ค่าต้องน้อยกว่าหรือเท่ากับ ${0}",
"minLength" : "โปรดขยายข้อความนี้ให้มีความยาว ${0} ตัวอักษรขึ้นไป.",
"maxLength" : "โปรดย่อข้อความนี้ให้เหลือ ${0} ตัวอักษรหรือน้อยกว่า.",
"step" : "กรุณาใส่ค่าที่ถูกต้อง.",
"format" : "ระบุค่าในรูปแบบที่อนุญาต : ${0}.",
"pattern" : "กรุณาตรงกับรูปแบบที่ร้องขอ.",
"minItems" : "ระบุจำนวนรายการเท่ากับหรือมากกว่า ${0}.",
"maxItems" : "ระบุจำนวนรายการเท่ากับหรือน้อยกว่า ${0}",
"uniqueItems" : "รายการทั้งหมดจะต้องไม่ซ้ำกัน",
"validationExpression" : "กรุณาใส่ค่าที่ถูกต้อง.",
"maxFileSize" : "ไฟล์มีขนาดใหญ่เกินไป ลดขนาดแล้วลองอีกครั้ง.",
"accept" : "ไม่รองรับประเภทไฟล์ที่ระบุ.",
"defaultError" : "มีข้อผิดพลาดในสนาม",
"clearText" : "ลอสเชน",
"0" : "",
"calendarSymbols" : {
"monthNames" : [
"มกราคม",
"กุมภาพันธ์",
"มีนาคม",
"เมษายน",
"พฤษภาคม",
"มิถุนายน",
"กรกฎาคม",
"สิงหาคม",
"กันยายน",
"ตุลาคม",
"พฤศจิกายน",
"ธันวาคม"
],
"abbrmonthNames" : [
"ม.ค.",
"ก.พ.",
"มี.ค.",
"เม.ย.",
"พ.ค.",
"มิ.ย.",
"ก.ค.",
"ส.ค.",
"ก.ย.",
"ต.ค.",
"พ.ย.",
"ธ.ค."
],
"dayNames" : [
"วันอาทิตย์",
"วันจันทร์",
"วันอังคาร",
"วันพุธ",
"วันพฤหัสบดี",
"วันศุกร์",
"วันเสาร์"
],
"abbrdayNames" : [
"อา.",
"จ.",
"อ.",
"พ.",
"พฤ.",
"ศ.",
"ส."
],
"meridiemNames" : [
"vorm.",
"nachm."
],
"eraNames" : [
"v. Chr.",
"n. Chr."
],
"day": "วัน",
"days": "วัน",
"month": "เดือน",
"months": "เดือน",
"year": "ปี",
"years": "ปี",
"more": "มากกว่า",
"less": "น้อย"
},
"Zero" : ""
}
25 changes: 11 additions & 14 deletions ui.frontend/src/LanguageUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,17 @@ class LanguageUtils {
* @fires module:FormView~Constants#FORM_LANGUAGE_INITIALIZED
*/
static async loadLang(lang, url, executeConfigsAndFireEvent = false) {
if (!(lang in this.#langData)) {
// todo: avoid doing this call in product json if locale not found
// todo: can't find a condition today, since language client library can be overlaid too
const _langData = await HTTPAPILayer.getJson(url);
if(_langData) {
console.debug("fetched language data", _langData);
this.#langData[lang] = _langData;
setCustomDefaultConstraintTypeMessages(_langData);
}
if (executeConfigsAndFireEvent) {
await this.#executeLanguageConfigs(lang);
const event = new CustomEvent(Constants.FORM_LANGUAGE_INITIALIZED, {"detail": lang});
document.dispatchEvent(event);
}
// someone can override the product locale as well, hence not adding this check --- if (!(lang in this.#langData))
const _langData = await HTTPAPILayer.getJson(url);
if(_langData) {
console.debug("fetched language data", _langData);
this.#langData[lang] = _langData;
setCustomDefaultConstraintTypeMessages(_langData);
}
if (executeConfigsAndFireEvent) {
await this.#executeLanguageConfigs(lang);
const event = new CustomEvent(Constants.FORM_LANGUAGE_INITIALIZED, {"detail": lang});
document.dispatchEvent(event);
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui.tests/test-module/libs/commons/localeDataSets.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const languages = [
"FileSizeGreater" : "파일 ${0}이(가) 예상 크기 ${1}MB를 초과합니다.",
"FileNameInvalid" : "파일 ${0}의 이름에 잘못된 문자가 포함되어 있습니다. 영숫자만 지원됩니다.",
"FileMimeTypeInvalid" : "파일 ${0}은(는) 지원되지 않는 파일 유형입니다.",
"InternalFormSubmissionError" : "양식을 제출하는 중 내부 오류가 발생했습니다."
"InternalFormSubmissionError" : "temp"
}
}, {
LANGUAGE: 'Chinese Traditional', LOCALE: 'zh-tw', TRANSLATION: {
Expand Down

0 comments on commit 47678c4

Please sign in to comment.