-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocales.js
More file actions
36 lines (26 loc) · 970 Bytes
/
locales.js
File metadata and controls
36 lines (26 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Polyglot
Copyright (C) LiveG. All Rights Reserved.
https://opensource.liveg.tech/polyglot
Licensed by the LiveG Open-Source Licence, which can be found at LICENCE.md.
*/
import * as projects from "./projects.js";
export function createLocale(projectId, localeCode, localeData, options = {}) {
projects.editProject(projectId, function(data) {
data.locales ||= {};
if (data.locales[localeCode]) {
throw new ReferenceError("The provided locale code already exists");
}
if (options.makeSource) {
localeData.isSource = true;
Object.keys(data.locales).forEach(function(localeCode) {
delete data.locales[localeCode].isSource;
});
}
data.locales[localeCode] = localeData;
});
projects.emit("localechanged", {localeCode});
}
export function getLocales(projectId) {
return projects.getProjects()[projectId].locales || {};
}