module translations getTranslations() enhancement
for module translations, is there any mechanism to select all files in the translations folder (without enumerating them in the getTranslations() call?
like "translations/*" means load them all.
that would make it easy for someone to add a new one, and NOT have to change the code...
yes it would be easier
Reading of the translations directory of the module
But... it will be more complicated to determine the default language file to use (actually the first one of getTranslations)
But... it will be more complicated to determine the default language file to use (actually the first one of
getTranslations)
So, in case of https://github.com/MichMich/MagicMirror/blob/abe5c08a52ffee6b37c30c1f3160e130f0e966a2/modules/default/alert/alert.js#L28 it would be "bulgaria" which is the default language?
but we have the language setting in config.js
sure, we know that ;)
sdetweil Idea is:
getTranslations() {
return {
files: "translations/*"
}
}
For read all files automaticaly files of translations folder of the module Maybe another function is needed
it's +/- your idea @sdetweil ? it's that?
but we have the language setting in config.js
but if json file of this translatated part don't exist ?
read all translations files available..
this would help a novice user create a new file , put it in folder, and it works.. doesn't have to edit source (which breaks updates)
what happens now?
read all translations files available..
this would help a novice user create a new file , put it in folder, and it works.. doesn't have to edit source (which breaks updates)
it's ok, we are talking about the same feature ;)
I had thought this:
- define a directory with translations
- create a json file with a new specificity / syntax
{
lang: [language tag]
default: [boolean]
translations: [object Translations]
}
- Read automatically this directory and make translations job
- use
defaultlang to apply for the module (fallback) - if getTranslations() used, ignore this rule
Yes i know, it's a shame not to have thought of this from the start.
BUT... that file would belong to the module and locally changed would break updates (even to include the new file)
yes and no, because there is une files by language too and can be added automaticaly
but yes, if you modify one of lang file, it's break update too but a new language file is added automaticaly without modify main core
but yes, if you modify one of lang file, it's break update too
trying to add function that helps and does not hurt the user..
I don't know if we can request a reloading of the translation files
otherwise my idea would be to go through the node helper with node fs
- read the contents of the directory (only json files)
- return the result.
- reload the transcription files with the result option
Note: I did not check if node js is available in a module core (I don't think so)
why reloading? on startup. read new list of files