-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGruntfile.js
More file actions
69 lines (53 loc) · 2.62 KB
/
Copy pathGruntfile.js
File metadata and controls
69 lines (53 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module.exports = function (grunt) {
/*
Use the tasks below to export strings that are marked for translation from the app, and import translated strings back into the app.
The app uses angular-gettext to provide the export, import and on-the-fly translation functions. https://angular-gettext.rocketeer.be/
Follow the guide on the angular-gettext website to learn how to mark a string for translation.
To use the tool
- Install grunt and angular-gettext, as per package.json
To export strings for translation:
- From the root of the app, run grunt nggettext_extract
- This will create a file located in languages/temple/template.po that indicates all of the strings that need to be translated. Have this file translated for each language.
To import strings that have been translated
- Copy the .po file for each language into the respectve folder in languages/language-code/language-code.po
- For example, the Russian translation should be located in languaged/ru/ru.po
- After all .po files have been copied into each language folder, from the root of the app, run grunt nggettext_compile.
- This takes all of the translated strings and copies them into .json files that are used by the app to provide translations.
To add support for a new language
- Create a new folder for the language under languages/language-code, for example, languages/ru for Russian.
- Have the template.po file translated into that language.
- Import the translated strings, as per the above section.
- Update $rootScope.languages in app/app.js with the language name and code
*/
/* Load tasks */
require('load-grunt-tasks')(grunt);
/* Configure project */
grunt.initConfig({
nggettext_extract: {
pot: {
files: {
'./languages/template/template.po': ['./*.html', './**/app/**/*.html', './dist/js/kit.js', './app/**/*.js', '!./node_modules/**']
}
}
},
nggettext_compile: {
all: {
options: {
format: "json"
},
files: [
{
expand: true,
dot: true,
src: ["./languages/**/*.po", "!./languages/template/*"],
ext: ".json"
}
]
},
}
});
// Allows to update modified files only.
grunt.loadNpmTasks('grunt-angular-gettext');
/* Register tasks */
grunt.registerTask('default', ['nggettext_extract', 'nggettext_compile']);
};