mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-01 21:43:26 +00:00
Merge pull request #238 from paviro/patch-3
Added getTranslations() to the documentation
This commit is contained in:
commit
b61d41f569
@ -97,7 +97,7 @@ start: function() {
|
|||||||
####`getScripts()`
|
####`getScripts()`
|
||||||
**Should return: Array**
|
**Should return: Array**
|
||||||
|
|
||||||
The getScripts method is called to request any additional scripts that need to be loaded. This method should therefor return an array with strings. If you want to return a full path to a file in the module folder, use the `this.file('filename.js')` method. In all cases the loader will only load a file once. It even checks if the file is available in the default vendor folder.
|
The getScripts method is called to request any additional scripts that need to be loaded. This method should therefore return an array with strings. If you want to return a full path to a file in the module folder, use the `this.file('filename.js')` method. In all cases the loader will only load a file once. It even checks if the file is available in the default vendor folder.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
````javascript
|
````javascript
|
||||||
@ -117,7 +117,7 @@ getScripts: function() {
|
|||||||
####`getStyles()`
|
####`getStyles()`
|
||||||
**Should return: Array**
|
**Should return: Array**
|
||||||
|
|
||||||
The getStyles method is called to request any additional scripts that need to be loaded. This method should therefor return an array with strings. If you want to return a full path to a file in the module folder, use the `this.file('filename.css')` method. In all cases the loader will only load a file once. It even checks if the file is available in the default vendor folder.
|
The getStyles method is called to request any additional stylesheets that need to be loaded. This method should therefore return an array with strings. If you want to return a full path to a file in the module folder, use the `this.file('filename.css')` method. In all cases the loader will only load a file once. It even checks if the file is available in the default vendor folder.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
````javascript
|
````javascript
|
||||||
@ -133,6 +133,22 @@ getStyles: function() {
|
|||||||
````
|
````
|
||||||
**Note:** If a file can not be loaded, the boot up of the mirror will stall. Therefore it's advised not to use any external urls.
|
**Note:** If a file can not be loaded, the boot up of the mirror will stall. Therefore it's advised not to use any external urls.
|
||||||
|
|
||||||
|
####`getTranslations()`
|
||||||
|
**Should return: Dictionary**
|
||||||
|
|
||||||
|
The getTranslations method is called to request translation files that need to be loaded. This method should therefore return a dictionary with the files to load, identified by the country's short name.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
````javascript
|
||||||
|
getTranslations: function() {
|
||||||
|
return {
|
||||||
|
en: "translations/en.json",
|
||||||
|
de: "translations/de.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
####`getDom()`
|
####`getDom()`
|
||||||
**Should return:** Dom Object
|
**Should return:** Dom Object
|
||||||
|
|
||||||
@ -448,6 +464,21 @@ Module.register("modulename",{
|
|||||||
//...
|
//...
|
||||||
});
|
});
|
||||||
````
|
````
|
||||||
|
## MagicMirror Translation
|
||||||
|
|
||||||
|
The Magic Mirror contains a convenience wrapper for `l18n`. You can use this to automatically serve different translations for your modules based on the user's `language` configuration.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
````javascript
|
||||||
|
this.translate("INFO") //Will return a translated string for the identifier INFO
|
||||||
|
````
|
||||||
|
|
||||||
|
**Example json file:**
|
||||||
|
````javascript
|
||||||
|
{
|
||||||
|
"INFO": "Really important information!"
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
## MagicMirror Logger
|
## MagicMirror Logger
|
||||||
|
|
||||||
@ -458,4 +489,4 @@ The Magic Mirror contains a convenience wrapper for logging. Currently, this log
|
|||||||
Log.info('error');
|
Log.info('error');
|
||||||
Log.log('log');
|
Log.log('log');
|
||||||
Log.error('info');
|
Log.error('info');
|
||||||
```
|
````
|
||||||
|
Loading…
x
Reference in New Issue
Block a user