angular-gettext 不从 .PO 文件中挑选字符串
angular-gettext does not pick the strings from .PO files
我已经根据文档安装了所有东西。有些东西正在按照文档工作。如果你 select 那些语言,是否有类似 Django 翻译的东西自动替换特定语言的翻译?
Index.html
<!DOCTYPE HTML>
<html>
{% load static %}
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
<script src="{% static 'first.js'%}"></script>
<script src="{% static '/angular-gettext/dist/angular-gettext.js'%}"></script>
<script type="text/javascript" >
angular.module('first').run(function (gettextCatalog) {
gettextCatalog.setCurrentLanguage('fr');
gettextCatalog.debug = true;
gettextCatalog.setStrings('fr', {
"Hello!":"Bonjour !"});
});
</script>
</head>
<body>
<div ng-app="first">
<translate>Hello!</translate> Sagar
<h1 translate>Hello!</h1>
</div>
</body>
</html>
PO 文件
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"X-Generator: Poedit 2.2.3\n"
"Last-Translator: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language: fr\n"
#: ui/templates/admin/firsttranslate/index.html:24
#: ui/templates/admin/firsttranslate/index.html:26
msgid "Hello!"
msgstr "Halo !"
当我 运行 我的代码搜索 Hello 并替换为 Bonjour 但我希望它像 Django 一样自动替换
提前致谢。
忘记在Gruntfile.js
中提到文件的路径
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
nggettext_extract: {
pot: {
files: {
'po/template.pot': ['ui/templates/admin/firsttranslate/*.html', 'js/first.js']
}
},
},
nggettext_compile: {
all: {
files: {
'js/translations.js': ['fr/LC_MESSAGES/djangojs.po']
}
},
},
});
grunt.loadNpmTasks('grunt-angular-gettext');
grunt.registerTask('default', ['nggettext_extract', 'nggettext_compile']);
};
我已经根据文档安装了所有东西。有些东西正在按照文档工作。如果你 select 那些语言,是否有类似 Django 翻译的东西自动替换特定语言的翻译?
Index.html
<!DOCTYPE HTML>
<html>
{% load static %}
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
<script src="{% static 'first.js'%}"></script>
<script src="{% static '/angular-gettext/dist/angular-gettext.js'%}"></script>
<script type="text/javascript" >
angular.module('first').run(function (gettextCatalog) {
gettextCatalog.setCurrentLanguage('fr');
gettextCatalog.debug = true;
gettextCatalog.setStrings('fr', {
"Hello!":"Bonjour !"});
});
</script>
</head>
<body>
<div ng-app="first">
<translate>Hello!</translate> Sagar
<h1 translate>Hello!</h1>
</div>
</body>
</html>
PO 文件
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"X-Generator: Poedit 2.2.3\n"
"Last-Translator: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language: fr\n"
#: ui/templates/admin/firsttranslate/index.html:24
#: ui/templates/admin/firsttranslate/index.html:26
msgid "Hello!"
msgstr "Halo !"
当我 运行 我的代码搜索 Hello 并替换为 Bonjour 但我希望它像 Django 一样自动替换 提前致谢。
忘记在Gruntfile.js
中提到文件的路径'use strict';
module.exports = function (grunt) {
grunt.initConfig({
nggettext_extract: {
pot: {
files: {
'po/template.pot': ['ui/templates/admin/firsttranslate/*.html', 'js/first.js']
}
},
},
nggettext_compile: {
all: {
files: {
'js/translations.js': ['fr/LC_MESSAGES/djangojs.po']
}
},
},
});
grunt.loadNpmTasks('grunt-angular-gettext');
grunt.registerTask('default', ['nggettext_extract', 'nggettext_compile']);
};