Skip to content

Commit

Permalink
MDL-75246 editor_tiny: Add initial translation support
Browse files Browse the repository at this point in the history
Part of MDL-75966

Add support for translation of the TinyMCE interface.

TinyMCE translates English language strings rather than keys, and a tool
to perform this translation is included.
  • Loading branch information
andrewnicols committed Nov 10, 2022
1 parent 7e5c81e commit d8cf77a
Show file tree
Hide file tree
Showing 8 changed files with 1,298 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/editor/tiny/amd/build/editor.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/editor/tiny/amd/build/editor.min.js.map

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions lib/editor/tiny/amd/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const importPluginList = async(pluginList) => {
};
};

const fetchLanguage = (language) => fetch(
`${M.cfg.wwwroot}/lib/editor/tiny/lang.php/${M.cfg.langrev}/${language}`
).then(response => response.json());

export const getAllInstances = () => new Map(instanceMap.entries());

/**
Expand Down Expand Up @@ -114,6 +118,14 @@ export const setupForElementId = ({elementId, options}) => {
return setupForTarget(target, options);
};

const initialisePage = async() => {
const lang = document.querySelector('html').lang;

const [tinyMCE, langData] = await Promise.all([getTinyMCE(), fetchLanguage(lang)]);
tinyMCE.addI18n(lang, langData);
};
initialisePage();

const getPlugins = (options) => {
if (options.plugins) {
return options.plugins;
Expand Down
Loading

0 comments on commit d8cf77a

Please sign in to comment.