@appscode/ui-builder
Version:
## Motivation
58 lines (52 loc) • 2.26 kB
JavaScript
import Vue from "vue";
import VueI18n from "vue-i18n";
import lang from "@/lang";
const messages = lang;
export function initializeVueI18n() {
Vue.use(VueI18n);
// Create VueI18n instance with options
const i18n = new VueI18n({
locale: "en", // set locale
messages, // set locale messages
});
return i18n;
}
export function addGlobalTranslateFunc(Vue, i18n) {
Vue.prototype.$ubt = (path) => {
const wizardPath = `$wizard.${path}`;
if (i18n.te(wizardPath)) return i18n.t(wizardPath);
else {
// first check if the path points to some of our keyword paths
// multistep sidebar title
if (path === "steps.title") return "STEPS";
// bottom control buttons
else if (path === "buttons.cancel") return "Cancel";
else if (path === "buttons.previous") return "Previous";
else if (path === "buttons.next") return "Next";
else if (path === "buttons.preview") return "Preview";
else if (path === "buttons.done") return "Done";
else if (path === "buttons.deploy") return "Deploy";
// array-input-form / object-input-form / list-input-form / keyvalue-input-form / single-step-form-arraybuttons
else if (path === "buttons.add_new") return "Add New";
else if (path === "buttons.show_value") return "Show Value";
else if (path === "buttons.view_more") return "View More";
else if (path === "buttons.new") return "New";
else if (path === "buttons.save") return "Save";
else if (path === "buttons.edit") return "Edit";
else if (path === "buttons.delete") return "Delete";
else if (path === "buttons.show_details") return "Show Details";
else if (path === "buttons.hide_details") return "Hide Details";
else if (path === "buttons.close") return "Close";
else if (path === "buttons.update") return "Update";
else if (path === "buttons.info") return "Description";
// code editor tabs
else if (path === "editor.tabs.code") return "Code";
else if (path === "editor.tabs.preview") return "Preview Changes";
// select box
else if (path === "select.add_new_option")
return "Add this as new option";
// else return the path itself
else return path;
}
};
}