Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Vietnamese (vi) locale #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ L.drawLocal = locale
| zh | Chinese |
| tr | Turkish |
| ro | Romanian |
| vi | Vietnamese |


## Submit a language
Expand All @@ -63,7 +64,7 @@ L.drawLocal = locale
- Copy-paste an existing `.ts` language from `src/locales/` as your template
- Include your new language in `src/index.ts`, it should be included at:
- The import at the top, import your new file
- The `language` contant should get the 2 letter identification for the language
- The `languages` contant should get the 2 letter identification for the language
- The switch-case should be updated to support cases for your language, setting the `locale` to the 2 letter code for the language
- The `Language` type should be edited to include a union of all possible cases for the language you added
- Include your language in the table in `README.md`
Expand Down
12 changes: 10 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import ar from "./locales/ar";
import zh from "./locales/zh";
import tr from "./locales/tr";
import ro from "./locales/ro";
import vi from "./locales/vi";

export const languages: Language[] = ["ar", "am", "cs", "de", "en", "es", "fi", "fr", "hu", "it", "ka", "nl", "no", "pl", "pt", "ru", "sk", "uk", "zh", "tr", "ro"];
export const languages: Language[] = ["ar", "am", "cs", "de", "en", "es", "fi", "fr", "hu", "it", "ka", "nl", "no", "pl", "pt", "ru", "sk", "uk", "zh", "tr", "ro", "vi"];

/**
* Localization for Leaflet.draw, changing between languages is now effortless.
Expand Down Expand Up @@ -204,6 +205,12 @@ export const drawLocales = (language: Language): DrawLocal => {
case "romanian":
locale = ro;
break;
case "vi":
case "vi-vn":
case "vi-vn.utf-8":
case "vietnamese":
locale = vi;
break;
default:
throw new Error("[language] not found");
}
Expand Down Expand Up @@ -244,7 +251,8 @@ export type Language =
| "hu" | "hu-HU" | "hu-hu" | "hu-HU.utf-8" | "hu-hu.utf-8" | "magyar" | "hungarian"
| "zh" | "zh-cn" | "zh-cn.utf-8" | "chinese"
| "tr" | "tr-tr" | "tr-tr.utf-8" | "turkish"
| "ro" | "ro-ro" | "ro-RO" | "ro-ro.utf-8" | "romanian";
| "ro" | "ro-ro" | "ro-RO" | "ro-ro.utf-8" | "romanian"
| "vi" | "vi-vn" | "vi-vn.utf-8" | "vietnamese";

export interface DrawLocal {
draw: Draw;
Expand Down
116 changes: 116 additions & 0 deletions src/locales/vi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { DrawHandlers, DrawToolbar, EditHandlers, EditToolbar } from "../index";

const drawToolbar: DrawToolbar = {
actions: {
title: "Huỷ hình vẽ",
text: "Huỷ",
},
finish: {
title: "Xong hình vẽ",
text: "Xong",
},
undo: {
title: "Xoá điểm vừa vẽ gần nhất",
text: "Xoá điểm vừa vẽ",
},
buttons: {
polyline: "Vẽ đường tự do",
polygon: "Vẽ đa giác tự do",
rectangle: "Vẽ hình chữ nhật",
circle: "Vẽ hình tròn",
marker: "Đánh dấu điểm",
circlemarker: "Khoanh tròn điểm",
},
};

const drawHandlers: DrawHandlers = {
circle: {
tooltip: {
start: "Nhấp và rê chuột để vẽ hình tròn.",
},
radius: "Bán kính",
},
circlemarker: {
tooltip: {
start: "Nhấp chuột lên bản đồ để khoanh tròn một điểm.",
},
},
marker: {
tooltip: {
start: "Nhấp chuột lên bản đồ để đánh dấu một điểm.",
},
},
polygon: {
tooltip: {
start: "Nhấp chuột để bắt đầu vẽ hình đa giác.",
cont: "Nhấp chuột để tiếp tục vẽ hình đa giác.",
end: "Nhấp chuột vào đỉnh đầu tiên để hoàn thiện hình đa giác.",
},
},
polyline: {
error: "<strong>Lỗi:</strong> Các đường không được cắt nhau!",
tooltip: {
start: "Nhấp chuột để bắt đầu vẽ đường.",
cont: "Nhấp chuột để tiếp tục vẽ đường.",
end: "Nhấp chuột vào điểm gấp khúc vừa vẽ để hoàn thiện đường.",
},
},
rectangle: {
tooltip: {
start: "Nhấp và rê chuột để vẽ hình chữ nhật.",
},
},
simpleshape: {
tooltip: {
end: "Nhả chuột để hoàn thiện hình.",
},
},
};

const editToolbar: EditToolbar = {
actions: {
save: {
title: "Lưu thay đổi.",
text: "Lưu",
},
cancel: {
title: "Dừng chỉnh sửa, huỷ toàn bộ thay đổi.",
text: "Huỷ",
},
clearAll: {
title: "Xoá toàn bộ các lớp.",
text: "Xoá tất cả",
},
},
buttons: {
edit: "Chỉnh sửa lớp.",
editDisabled: "Không có lớp nào để chỉnh sửa.",
remove: "Xoá lớp.",
removeDisabled: "Không có lớp nào để xoá.",
},
};

const editHandlers: EditHandlers = {
edit: {
tooltip: {
text: "Di chuyển các điểm tay nắm để chỉnh sửa hình vẽ.",
subtext: "Bấm Huỷ để khôi phục hình vẽ ban đầu.",
},
},
remove: {
tooltip: {
text: "Nhấp chuột vào hình vẽ để xoá đi",
},
},
};

export default {
draw: {
toolbar: drawToolbar,
handlers: drawHandlers,
},
edit: {
toolbar: editToolbar,
handlers: editHandlers,
},
};