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

expose translations in global Alchemy js object, #2113 #2114

Merged
merged 1 commit into from
Jun 4, 2021
Merged
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
2 changes: 2 additions & 0 deletions package/admin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import translate from "./src/i18n"
import translationData from "./src/translations"
import NodeTree from "./src/node_tree"
import fileEditors from "./src/file_editors"
import pictureEditors from "./src/picture_editors"
Expand All @@ -14,6 +15,7 @@ if (typeof window.Alchemy === "undefined") {
Object.assign(Alchemy, {
// Global utility method for translating a given string
t: translate,
translations: Object.assign(Alchemy.translations || {}, translationData),
NodeTree,
fileEditors,
pictureEditors,
Expand Down
4 changes: 1 addition & 3 deletions package/src/i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import translationData from "./translations"

const KEY_SEPARATOR = /\./

function currentLocale() {
Expand All @@ -11,7 +9,7 @@ function currentLocale() {

function getTranslations() {
const locale = currentLocale()
const translations = translationData[locale]
const translations = Alchemy.translations[locale]

if (translations) {
return translations
Expand Down