diff --git a/export-i18n.sh b/export-i18n.sh new file mode 100644 index 0000000..a9c9ff1 --- /dev/null +++ b/export-i18n.sh @@ -0,0 +1,3 @@ +#! sh +xgettext-template -D lib/client/html -L Handlebars *.html -o i18n/en.i18n.po +i18next-conv -l en -s i18n/en.i18n.po -t i18n/en.i18n.json diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json new file mode 100644 index 0000000..1b30341 --- /dev/null +++ b/i18n/en.i18n.json @@ -0,0 +1,28 @@ +{ + "Admin": "", + "Toggle navigation": "", + "Home": "", + "Your profile": "", + "Sign out": "", + "Dashboard": "", + "New": "", + "Edit": "", + "Confirm delete": "", + "Are you sure you want to delete this?": "", + "You need to be an admin to view this page": "", + "You need to define an AdminConfig object to use the admin dashboard.": "", + "A basic config to manage the 'Posts' and 'Comments' collection would look like this:": "", + "View All": "", + "There are no visible items in this collection.": "", + "Add one": "", + "Add User": "", + "Click a role to toggle it.": "", + "User not in any roles. Click a role to add it to a user.": "", + "Reset Password": "", + "Send a reset password email to": "", + "Send Email": "", + "Change Password": "", + "ID": "", + "Delete": "", + "See all": "" +} \ No newline at end of file diff --git a/i18n/en.i18n.po b/i18n/en.i18n.po new file mode 100644 index 0000000..0d3346a --- /dev/null +++ b/i18n/en.i18n.po @@ -0,0 +1,114 @@ +msgid "" +msgstr "Content-Type: text/plain;\n" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_header.html:7 +msgid "Admin" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_header.html:13 +msgid "Toggle navigation" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_header.html:22 +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_header.html:24 +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_header.html:30 +msgid "Home" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_header.html:35 +msgid "Your profile" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_header.html:39 +msgid "Sign out" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_layouts.html:18 +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_sidebar.html:19 +msgid "Dashboard" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_layouts.html:24 +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_sidebar.html:30 +msgid "New" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_layouts.html:28 +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:145 +msgid "Edit" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_layouts.html:61 +msgid "Confirm delete" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_layouts.html:64 +msgid "Are you sure you want to delete this?" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_layouts.html:80 +msgid "You need to be an admin to view this page" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_layouts.html:89 +msgid "You need to define an AdminConfig object to use the admin dashboard." +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_layouts.html:91 +msgid "" +"A basic config to manage the 'Posts' and 'Comments' collection would look " +"like this:" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_sidebar.html:31 +msgid "View All" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:49 +msgid "There are no visible items in this collection." +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:50 +msgid "Add one" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:70 +msgid "Add User" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:91 +msgid "Click a role to toggle it." +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:93 +msgid "User not in any roles. Click a role to add it to a user." +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:97 +msgid "Reset Password" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:104 +msgid "Send a reset password email to" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:105 +msgid "Send Email" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:109 +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:117 +msgid "Change Password" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:112 +msgid "ID" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_templates.html:150 +msgid "Delete" +msgstr "" + +#: /home/xaiki/src/enre/gaz/packages/yogiben:admin/lib/client/html/admin_widgets.html:26 +msgid "See all" +msgstr "" \ No newline at end of file diff --git a/i18n/es.i18n.json b/i18n/es.i18n.json new file mode 100644 index 0000000..c35f36e --- /dev/null +++ b/i18n/es.i18n.json @@ -0,0 +1,28 @@ +{ + "Admin": "Administrador", + "Toggle navigation": "", + "Home": "Inicio", + "Your profile": "Su Perfil", + "Sign out": "Desconectarse", + "Dashboard": "Panel de Control", + "New": "Nuevo", + "Edit": "Editar", + "Confirm delete": "Confirme la supresion", + "Are you sure you want to delete this?": "¿ Esta seguro que quiere suprimir esto ?", + "You need to be an admin to view this page": "Necesita privilegios de administrador para ver esta pagina", + "You need to define an AdminConfig object to use the admin dashboard.": "Necesita definir un objeto 'AdminConfig' para utilizar este panel de control de administrador", + "A basic config to manage the 'Posts' and 'Comments' collection would look like this:": "", + "View All": "Una configuración basica para controlar las colecciones 'Posts' y 'Comments' se veria algo asi:", + "There are no visible items in this collection.": "No hay elementos visibles en esta coleccion", + "Add one": "Agregar uno", + "Add User": "Agregar Usuario", + "Click a role to toggle it.": "Haga click en un rol para activarlo", + "User not in any roles. Click a role to add it to a user.": "Este usuario no esta en ningun rol. Haga click sobre un rol para agregarlo a un usuario", + "Reset Password": "Resetear la Clave", + "Send a reset password email to": "Mandar una petición de reset de clave por email a", + "Send Email": "Mandar Email", + "Change Password": "Cambiar la clave", + "ID": "ID", + "Delete": "Suprimir", + "See all": "Ver todos" +} diff --git a/lib/both/AdminDashboard.coffee b/lib/both/AdminDashboard.coffee index 0673fc5..22950d8 100644 --- a/lib/both/AdminDashboard.coffee +++ b/lib/both/AdminDashboard.coffee @@ -52,18 +52,18 @@ AdminDashboard = AdminDashboard.schemas.newUser = new SimpleSchema email: type: String - label: "Email address" + label: __ "Email address" chooseOwnPassword: type: Boolean - label: 'Let this user choose their own password with an email' + label: __ 'Let this user choose their own password with an email' defaultValue: true password: type: String - label: 'Password' + label: __ 'Password' optional: true sendPassword: type: Boolean - label: 'Send this user their password by email' + label: __ 'Send this user their password by email' optional: true AdminDashboard.schemas.sendResetPasswordEmail = new SimpleSchema diff --git a/lib/both/router.coffee b/lib/both/router.coffee index 46b39cf..dc85545 100644 --- a/lib/both/router.coffee +++ b/lib/both/router.coffee @@ -21,7 +21,7 @@ Meteor.call 'adminCheckAdmin' if typeof AdminConfig?.nonAdminRedirectRoute == 'string' Router.go AdminConfig.nonAdminRedirectRoute - + @next() @@ -32,7 +32,7 @@ Router.route "adminDashboard", action: -> @render() onAfterAction: -> - Session.set 'admin_title', 'Dashboard' + Session.set 'admin_title', __ 'Dashboard' Session.set 'admin_collection_name', '' Session.set 'admin_collection_page', '' @@ -43,10 +43,10 @@ Router.route "adminDashboardUsersNew", action: -> @render() onAfterAction: -> - Session.set 'admin_title', 'Users' - Session.set 'admin_subtitle', 'Create new user' - Session.set 'admin_collection_page', 'New' - Session.set 'admin_collection_name', 'Users' + Session.set 'admin_title', __ 'Users' + Session.set 'admin_subtitle', __ 'Create new user' + Session.set 'admin_collection_page', __ 'New' + Session.set 'admin_collection_name', __ 'Users' Router.route "adminDashboardUsersEdit", path: "/admin/Users/:_id/edit" @@ -76,7 +76,7 @@ Router.route "adminDashboardView", @render() onAfterAction: -> Session.set 'admin_title', @params.collection - Session.set 'admin_subtitle', 'View' + Session.set 'admin_subtitle', __ 'View' Session.set 'admin_collection_name', @params.collection Router.route "adminDashboardNew", @@ -87,8 +87,8 @@ Router.route "adminDashboardNew", @render() onAfterAction: -> Session.set 'admin_title', AdminDashboard.collectionLabel(@params.collection) - Session.set 'admin_subtitle', 'Create new' - Session.set 'admin_collection_page', 'new' + Session.set 'admin_subtitle', __ 'Create new' + Session.set 'admin_collection_page', __ 'new' Session.set 'admin_collection_name', @params.collection.charAt(0).toUpperCase() + @params.collection.slice(1) data: -> admin_collection: adminCollectionObject @params.collection @@ -103,10 +103,10 @@ Router.route "adminDashboardEdit", @render() onAfterAction: -> Session.set 'admin_title', AdminDashboard.collectionLabel @params.collection - Session.set 'admin_subtitle', 'Edit ' + @params._id - Session.set 'admin_collection_page', 'edit' + Session.set 'admin_subtitle', __ 'Edit ' + @params._id + Session.set 'admin_collection_page', __ 'edit' Session.set 'admin_collection_name', @params.collection.charAt(0).toUpperCase() + @params.collection.slice(1) Session.set 'admin_id', @params._id Session.set 'admin_doc', adminCollectionObject(@params.collection).findOne _id : @params._id data: -> - admin_collection: adminCollectionObject @params.collection \ No newline at end of file + admin_collection: adminCollectionObject @params.collection diff --git a/lib/both/startup.coffee b/lib/both/startup.coffee index 8e44832..b520dbe 100644 --- a/lib/both/startup.coffee +++ b/lib/both/startup.coffee @@ -4,7 +4,7 @@ adminTablesDom = '<"box"<"box-header"<"box-toolbar"<"pull-left"><"pull-right adminEditDelButtons = [ { data: '_id' - title: 'Edit' + title: __ 'Edit' createdCell: (node, cellData, rowData) -> $(node).html(Blaze.toHTMLWithData Template.adminEditBtn, {_id: cellData}, node) width: '40px' @@ -12,7 +12,7 @@ adminEditDelButtons = [ } { data: '_id' - title: 'Delete' + title: __ 'Delete' createdCell: (node, cellData, rowData) -> $(node).html(Blaze.toHTMLWithData Template.adminDeleteBtn, {_id: cellData}, node) width: '40px' @@ -26,12 +26,12 @@ defaultColumns = [ ] AdminTables.Users = new Tabular.Table - name: 'Users' + name: __ 'Users' collection: Meteor.users columns: _.union [ { data: '_id' - title: 'Admin' + title: __ 'Admin' # TODO: use `tmpl` createdCell: (node, cellData, rowData) -> $(node).html(Blaze.toHTMLWithData Template.adminUsersIsAdmin, {_id: cellData}, node) @@ -39,19 +39,19 @@ AdminTables.Users = new Tabular.Table } { data: 'emails' - title: 'Email' + title: __ 'Email' render: (value) -> value[0].address } { data: 'emails' - title: 'Mail' + title: __ 'Mail' # TODO: use `tmpl` createdCell: (node, cellData, rowData) -> $(node).html(Blaze.toHTMLWithData Template.adminUsersMailBtn, {emails: cellData}, node) width: '40px' } - { data: 'createdAt', title: 'Joined' } + { data: 'createdAt', title: __ 'Joined' } ], adminEditDelButtons dom: adminTablesDom diff --git a/lib/both/utils.coffee b/lib/both/utils.coffee index 5d25be7..c19f955 100644 --- a/lib/both/utils.coffee +++ b/lib/both/utils.coffee @@ -19,7 +19,7 @@ arr = obj.split '.' continue while arr.length and (ref = ref[arr.shift()]) if not ref and required - throw new Error(obj + ' is not in the ' + root.toString()) + throw new Error(obj + __ (' is not in the ') + root.toString()) else return ref - return obj \ No newline at end of file + return obj diff --git a/lib/client/html/admin_header.html b/lib/client/html/admin_header.html index 326212a..b552024 100644 --- a/lib/client/html/admin_header.html +++ b/lib/client/html/admin_header.html @@ -4,13 +4,13 @@ {{#if AdminConfig.name}} {{AdminConfig.name}} {{else}} - Admin + {{_ "Admin"}} {{/if}} - \ No newline at end of file + diff --git a/lib/client/html/admin_layouts.html b/lib/client/html/admin_layouts.html index 7e4f25b..1e58198 100644 --- a/lib/client/html/admin_layouts.html +++ b/lib/client/html/admin_layouts.html @@ -15,20 +15,20 @@

{{#if $.Session.get 'admin_collection_name'}} @@ -58,10 +58,10 @@

{{/with}}

- \ No newline at end of file + diff --git a/package-tap.i18n b/package-tap.i18n new file mode 100644 index 0000000..bb3254c --- /dev/null +++ b/package-tap.i18n @@ -0,0 +1,16 @@ +{ + // The name for the translation function that + // will be available in package's namespace. + "translation_function_name": "__", + + // the name for the package templates' translation helper + "helper_name": "_", + + // tap:i18n automatically separates the translation strings of each package to a + // namespace dedicated to that package, which is used by the package's translation + // function and helper. Use the namespace option to set a custom namespace for + // the package. By using the name of another package you can use your package to + // add to that package or modify its translations. You can also set the namespace to + // "project" to add translations that will be available in the project level. + "namespace": "admin" +} diff --git a/package.js b/package.js index caef1c2..87e0fa1 100644 --- a/package.js +++ b/package.js @@ -23,7 +23,8 @@ Package.on_use(function(api){ 'reywood:publish-composite@1.3.5', 'momentjs:moment@2.9.0', 'aldeed:tabular@1.0.6', - 'meteorhacks:unblock@1.1.0' + 'meteorhacks:unblock@1.1.0', + 'tap:i18n@1.4.1' ], both); @@ -32,11 +33,14 @@ Package.on_use(function(api){ api.use(['email'],'server') api.add_files([ + 'package-tap.i18n', 'lib/both/AdminDashboard.coffee', 'lib/both/router.coffee', 'lib/both/utils.coffee', 'lib/both/startup.coffee', - 'lib/both/collections.coffee' + 'lib/both/collections.coffee', + // tap + 'i18n/en.i18n.json', ], both); api.add_files([