Skip to content
This repository
Browse code

Documenting current workflow while writing blog post

  • Loading branch information...
commit 2bec592e247aeda3922d497e4e15dbde738c81e9 1 parent f2db522
Austin King authored January 30, 2013
5  bin/compile-json.sh
@@ -28,8 +28,11 @@ for pofile in `find $1 -type f -name "*.po"`; do
28 28
     stem=`basename $pofile .po`
29 29
     jsonfile="$2/${lang}/${stem}.json"
30 30
     mkdir -p $2/${lang}
  31
+echo "I am working in "
  32
+pwd
  33
+echo "and 1 is $1 and 2 is $2"
31 34
     echo -n ";var json_locale_data = " > $jsonfile
32  
-    $1/po2json.js -p  $pofile >> $jsonfile
  35
+    ./node_modules/.bin/po2json.js -p  $pofile >> $jsonfile
33 36
     echo ";" >> $jsonfile
34 37
 done
35 38
 rm $lockfile
4  docs/USAGE.md
Source Rendered
@@ -40,6 +40,10 @@ config file which you'll like to validate. Examples:
40 40
     CONFIG_FILES=/home/ozten/Projects/browserid/config/l10n-prod.json node ./scripts/check-l10n-config.js
41 41
     CONFIG_FILES=/home/ozten/Projects/browserid/config/l10n-all.json node ./scripts/check-l10n-config.js
42 42
 
  43
+## Contributions
  44
+
  45
+``scripts/check-po.sh`` - Prints statistics on various .po files, assumes `locale` directory.
  46
+
43 47
 ## Debugging
44 48
 
45 49
 If code is evaluated in node.js (server-side) then node-gettext is providing the string
2  examples/express2/app.js
@@ -38,6 +38,6 @@ app.configure('production', function(){
38 38
 
39 39
 app.get('/', routes.index);
40 40
 
41  
-app.listen(3000, function(){
  41
+app.listen(3001, function(){
42 42
   console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
43 43
 });
12  examples/express2/i18n/db_LB/messages.json
... ...
@@ -0,0 +1,12 @@
  1
+;var json_locale_data = {
  2
+   "messages": {
  3
+      "": {
  4
+         "Project-Id-Version": " express 2\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2012-06-24 09:50+0200\nPO-Revision-Date: 2012-06-24 09:50+0200\nLast-Translator: Automatically generated\nLanguage-Team: none\nLanguage: db_LB\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n"
  5
+      },
  6
+      "Hello, world!": [
  7
+         null,
  8
+         ""
  9
+      ]
  10
+   }
  11
+}
  12
+;
12  examples/express2/i18n/de/messages.json
... ...
@@ -0,0 +1,12 @@
  1
+;var json_locale_data = {
  2
+   "messages": {
  3
+      "": {
  4
+         "Project-Id-Version": " express 2\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2012-06-24 09:50+0200\nPO-Revision-Date: 2012-06-24 09:50+0200\nLast-Translator: Automatically generated\nLanguage-Team: none\nLanguage: de\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n != 1);\n"
  5
+      },
  6
+      "Hello, world!": [
  7
+         null,
  8
+         ""
  9
+      ]
  10
+   }
  11
+}
  12
+;
12  examples/express2/i18n/en_US/messages.json
... ...
@@ -0,0 +1,12 @@
  1
+;var json_locale_data = {
  2
+   "messages": {
  3
+      "": {
  4
+         "Project-Id-Version": " express 2\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2012-06-24 09:50+0200\nPO-Revision-Date: 2012-06-24 09:50+0200\nLast-Translator: Automatically generated\nLanguage-Team: none\nLanguage: en_US\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n != 1);\n"
  5
+      },
  6
+      "Hello, world!": [
  7
+         null,
  8
+         "Hello, world!"
  9
+      ]
  10
+   }
  11
+}
  12
+;
12  examples/express2/i18n/es/messages.json
... ...
@@ -0,0 +1,12 @@
  1
+;var json_locale_data = {
  2
+   "messages": {
  3
+      "": {
  4
+         "Project-Id-Version": " express 2\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2012-06-24 09:50+0200\nPO-Revision-Date: 2012-06-24 09:50+0200\nLast-Translator: Automatically generated\nLanguage-Team: none\nLanguage: es\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n != 1);\n"
  5
+      },
  6
+      "Hello, world!": [
  7
+         null,
  8
+         ""
  9
+      ]
  10
+   }
  11
+}
  12
+;
22  examples/express2/scripts/extract-json-only.sh
... ...
@@ -0,0 +1,22 @@
  1
+#!/bin/bash
  2
+
  3
+echo "Extracting strings"
  4
+mkdir -p locale/templates/LC_MESSAGES
  5
+./node_modules/i18n-abide/bin/extract-pot -l ./locale .
  6
+
  7
+# Create PO files
  8
+for locale in en_US es de db_LB; do
  9
+  echo "Creating ${locale} language files"
  10
+  mkdir -p locale/${locale}/LC_MESSAGES
  11
+  mkdir -p i18n/${locale}
  12
+  msginit --input=./locale/templates/LC_MESSAGES/messages.pot \
  13
+          --output-file=./locale/${locale}/LC_MESSAGES/messages.po \
  14
+          -l ${locale} --no-translator
  15
+  echo "You can translate i18n/${locale}/messages.json"
  16
+done
  17
+
  18
+# Convert PO files to JSON
  19
+./node_modules/i18n-abide/bin/compile-json.sh locale i18n
  20
+
  21
+# Make current version of the code happy
  22
+./node_modules/i18n-abide/bin/compile-mo.sh locale
9  lib/i18n.js
@@ -68,16 +68,21 @@ exports.abide = function (options) {
68 68
   options.supported_languages.forEach(function (lang, i) {
69 69
     var l = localeFrom(lang),
70 70
         default_locale = localeFrom(options.default_lang);
71  
-
  71
+    console.log(l, mo_file_path(l), exists(mo_file_path(l)));
72 72
     mo_cache[l] = {
73  
-      mo_exists: path.exists(mo_file_path(l)),
  73
+      mo_exists: exists(mo_file_path(l)),
74 74
       /* json_exists: path.exists(json_file_path(l)), */
75 75
       gt: null
76 76
     };
77 77
     if (l !== debug_locale) {
78 78
       if (! mo_cache[l] || ! mo_cache[l].mo_exists /* || ! mo_cache[l].json_exists*/ ) {
  79
+
  80
+	console.log('mo_cache?', mo_cache[l], ' for ', l);
  81
+	if (mo_cache[l]) console.log('mo_exists?', mo_cache[l].mo_exists);
79 82
         var msg = util.format('Bad locale=[%s] file(s) do not exist [%s]. See locale/README',
80 83
                               l, mo_file_path(l)/*, json_file_path(l)*/);
  84
+
  85
+	console.log(l, default_locale);
81 86
         if (/* mo_cache[l].json_exists && */ l == default_locale) {
82 87
           // mo files aren't critical... carry on
83 88
           if (! options.disable_locale_check) logger.warn(msg);
2  package.json
@@ -2,7 +2,7 @@
2 2
   "author": "Austin King <shout@ozten.com> (http://ozten.com)",
3 3
   "name": "i18n-abide",
4 4
   "description": "Express/connect module for Node i18n and l10n support",
5  
-  "version": "0.0.7",
  5
+  "version": "0.0.8beta",
6 6
   "homepage": "https://github.com/mozilla/i18n-abide",
7 7
   "repository": {
8 8
     "type": "git",

0 notes on commit 2bec592

Please sign in to comment.
Something went wrong with that request. Please try again.