Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add an example locale/ directory

  • Loading branch information...
commit b1122b4a775ce78730a72ec59b6c26ef89fe6e2c 1 parent 9908571
Staś Małolepszy authored June 03, 2011
2  .gitignore
@@ -14,4 +14,4 @@ vendor
14 14
 .noseids
15 15
 tmp/*
16 16
 *~
17  
-locale/*
  17
+*.mo
37  bin/autol10n.sh
... ...
@@ -1,37 +0,0 @@
1  
-#!/bin/bash
2  
-
3  
-# Automatically pull L10n dirs from SVN, compile, then push to git.
4  
-# Runs on all project dirs named *-autol10n.
5  
-
6  
-# Settings
7  
-GIT=`/usr/bin/which git`
8  
-FIND=`/usr/bin/which find`
9  
-DEVDIR=$HOME/dev
10  
-
11  
-# Update everything
12  
-for dir in `$FIND "$DEVDIR" -maxdepth 1 -name '*-autol10n'`; do
13  
-cd $dir
14  
-    $GIT pull -q origin master
15  
-    cd locale
16  
-    $GIT svn rebase
17  
-
18  
-    # Compile .mo, commit if changed
19  
-    ./compile-mo.sh .
20  
-    $FIND . -name '*.mo' -exec $GIT add {} \;
21  
-    $GIT status
22  
-    if [ $? -eq 0 ]; then
23  
-        $GIT commit -m 'compiled .mo files (automatic commit)'
24  
-    fi
25  
-
26  
-    # Push to SVN and git
27  
-    $GIT svn dcommit && $GIT push -q origin master
28  
-
29  
-    cd ..
30  
-
31  
-    $GIT add locale
32  
-    $GIT status locale
33  
-    if [ $? -eq 0 ]; then
34  
-        $GIT commit -m 'L10n update (automatic commit)'
35  
-        $GIT push -q origin master
36  
-    fi
37  
-done
19  bin/compile-mo.sh
... ...
@@ -1,19 +1,28 @@
1 1
 #!/bin/bash
2 2
 
3  
-# syntax:
4  
-# compile-mo.sh locale-dir/
  3
+TARGET=$1
  4
+LOCKFILE="/tmp/compile-mo-${2}.lock"
5 5
 
6 6
 function usage() {
7 7
     echo "syntax:"
8  
-    echo "compile.sh locale-dir/"
  8
+    echo "  compile-mo.sh locale-dir/ [unique]"
  9
+    echo "unique is an optional string that will be used as the name of the lockfile"
9 10
     exit 1
10 11
 }
11 12
 
12 13
 # check if file and dir are there
13  
-if [[ ($# -ne 1) || (! -d "$1") ]]; then usage; fi
  14
+if [[ ($# -gt 2) || (! -d "$TARGET") ]]; then usage; fi
14 15
 
15  
-for lang in `find $1 -type f -name "*.po"`; do
  16
+# check if the lockfile exists
  17
+if [ -e $LOCKFILE ]; then
  18
+    echo "$LOCKFILE present, exiting"
  19
+    exit 99
  20
+fi
  21
+
  22
+touch $LOCKFILE
  23
+for lang in `find $TARGET -type f -name "*.po"`; do
16 24
     dir=`dirname $lang`
17 25
     stem=`basename $lang .po`
18 26
     msgfmt -o ${dir}/${stem}.mo $lang
19 27
 done
  28
+rm $LOCKFILE
29  bin/update_site.py 100644 → 100755
@@ -16,6 +16,7 @@
16 16
 import sys
17 17
 from textwrap import dedent
18 18
 from optparse import  OptionParser
  19
+from hashlib import md5
19 20
 
20 21
 # Constants
21 22
 PROJECT = 0
@@ -28,10 +29,17 @@
28 29
     'prod':  ['prod',   'master'],
29 30
 }
30 31
 
  32
+# The URL of the SVN repository with the localization files (*.po). If you set 
  33
+# it to a non-empty value, remember to `git rm --cached -r locale` in the root 
  34
+# of the project.  Example:
  35
+# LOCALE_REPO_URL = 'https://svn.mozilla.org/projects/l10n-misc/trunk/playdoh/locale'
  36
+LOCALE_REPO_URL = ''
  37
+
31 38
 GIT_PULL = "git pull -q origin %(branch)s"
32 39
 GIT_SUBMODULE = "git submodule update --init"
  40
+SVN_CO = "svn checkout --force %(url)s locale"
33 41
 SVN_UP = "svn update"
34  
-COMPILE_PO = "./compile.sh"
  42
+COMPILE_MO = "./bin/compile-mo.sh %(localedir)s %(unique)s"
35 43
 
36 44
 EXEC = 'exec'
37 45
 CHDIR = 'chdir'
@@ -41,6 +49,8 @@ def update_site(env, debug):
41 49
     """Run through commands to update this site."""
42 50
     error_updating = False
43 51
     here = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
  52
+    locale = os.path.join(here, 'locale')
  53
+    unique = md5(locale).hexdigest()
44 54
     project_branch = {'branch': ENV_BRANCH[env][PROJECT]}
45 55
     vendor_branch = {'branch': ENV_BRANCH[env][VENDOR]}
46 56
 
@@ -50,17 +60,24 @@ def update_site(env, debug):
50 60
         (EXEC,  GIT_SUBMODULE),
51 61
     ]
52 62
 
  63
+    # Checkout the locale repo into locale/ if the URL is known
  64
+    if LOCALE_REPO_URL and not os.path.exists(os.path.join(locale, '.svn')):
  65
+        commands += [
  66
+            (EXEC, SVN_CO % {'url': LOCALE_REPO_URL}),
  67
+            (EXEC, COMPILE_MO % {'localedir': locale, 'unique': unique}),
  68
+        ]
  69
+
53 70
     # Update locale dir if applicable
54  
-    if os.path.exists(os.path.join(here, 'locale', '.svn')):
  71
+    if os.path.exists(os.path.join(locale, '.svn')):
55 72
         commands += [
56  
-            (CHDIR, os.path.join(here, 'locale')),
  73
+            (CHDIR, locale),
57 74
             (EXEC, SVN_UP),
58  
-            (EXEC, COMPILE_PO),
59 75
             (CHDIR, here),
  76
+            (EXEC, COMPILE_MO % {'localedir': locale, 'unique': unique}),
60 77
         ]
61  
-    elif os.path.exists(os.path.join(here, 'locale', '.git')):
  78
+    elif os.path.exists(os.path.join(locale, '.git')):
62 79
         commands += [
63  
-            (CHDIR, os.path.join(here, 'locale')),
  80
+            (CHDIR, locale),
64 81
             (EXEC, GIT_PULL % 'master'),
65 82
             (CHDIR, here),
66 83
         ]
31  locale/en_US/LC_MESSAGES/messages.po
... ...
@@ -0,0 +1,31 @@
  1
+msgid ""
  2
+msgstr ""
  3
+"Project-Id-Version: PACKAGE VERSION\n"
  4
+"Report-Msgid-Bugs-To: \n"
  5
+"POT-Creation-Date: 2011-05-26 18:11-0700\n"
  6
+"PO-Revision-Date: 2011-05-26 18:11-0700\n"
  7
+"Last-Translator: Automatically generated\n"
  8
+"Language-Team: none\n"
  9
+"Language: en_US\n"
  10
+"MIME-Version: 1.0\n"
  11
+"Content-Type: text/plain; charset=UTF-8\n"
  12
+"Content-Transfer-Encoding: 8bit\n"
  13
+"X-Generator: Translate Toolkit 1.8.0\n"
  14
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
  15
+
  16
+#: apps/examples/templates/examples/home.html:5
  17
+msgid "Hello world"
  18
+msgstr "Hello world"
  19
+
  20
+#. This is a localizer comment
  21
+#: apps/examples/templates/examples/home.html:9
  22
+msgid "This is a <em>test view</em>."
  23
+msgstr "This is a <em>test view</em>."
  24
+
  25
+#: apps/examples/templates/examples/home.html:11
  26
+msgid "<a href=\"%(docs_url)s\">Learn you some Playdoh</a> and then go build something <strong>awesome</strong>."
  27
+msgstr "<a href=\"%(docs_url)s\">Learn you some Playdoh</a> and then go build something <strong>awesome</strong>."
  28
+
  29
+#: apps/examples/templates/examples/home.html:17
  30
+msgid "Current locale: %(LANG)s.<br> Available locales: %(langs)s."
  31
+msgstr "Current locale: %(LANG)s.<br> Available locales: %(langs)s."
29  locale/fr/LC_MESSAGES/messages.po
... ...
@@ -0,0 +1,29 @@
  1
+msgid ""
  2
+msgstr ""
  3
+"Project-Id-Version: PACKAGE VERSION\n"
  4
+"Report-Msgid-Bugs-To: \n"
  5
+"POT-Creation-Date: 2011-06-03 19:07-0700\n"
  6
+"Last-Translator: Automatically generated\n"
  7
+"Language-Team: none\n"
  8
+"Language: fr\n"
  9
+"MIME-Version: 1.0\n"
  10
+"Content-Type: text/plain; charset=UTF-8\n"
  11
+"Content-Transfer-Encoding: 8bit\n"
  12
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
  13
+
  14
+#: apps/examples/templates/examples/home.html:5
  15
+msgid "Hello world"
  16
+msgstr "Bonjour le monde"
  17
+
  18
+#. This is a localizer comment
  19
+#: apps/examples/templates/examples/home.html:9
  20
+msgid "This is a <em>test view</em>."
  21
+msgstr "Ceci est une <em>vue de test</em>."
  22
+
  23
+#: apps/examples/templates/examples/home.html:11
  24
+msgid "<a href=\"%(docs_url)s\">Learn you some Playdoh</a> and then go build something <strong>awesome</strong>."
  25
+msgstr "<a href=\"%(docs_url)s\">Apprends à jouer avec Playdoh</a> et construis quelque chose de <strong>génial</strong>."
  26
+
  27
+#: apps/examples/templates/examples/home.html:17
  28
+msgid "Current locale: %(LANG)s.<br> Available locales: %(langs)s."
  29
+msgstr "Langue active&nbsp;: %(LANG)s.<br> Langues disponibles&nbsp;: %(langs)s."
32  locale/templates/LC_MESSAGES/messages.pot
... ...
@@ -0,0 +1,32 @@
  1
+#, fuzzy
  2
+msgid ""
  3
+msgstr ""
  4
+"Project-Id-Version: PACKAGE VERSION\n"
  5
+"Report-Msgid-Bugs-To: \n"
  6
+"POT-Creation-Date: 2011-06-03 19:07-0700\n"
  7
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
  8
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
  9
+"Language-Team: LANGUAGE <LL@li.org>\n"
  10
+"MIME-Version: 1.0\n"
  11
+"Content-Type: text/plain; charset=utf-8\n"
  12
+"Content-Transfer-Encoding: 8bit\n"
  13
+"X-Generator: Translate Toolkit 1.8.0\n"
  14
+
  15
+#: apps/examples/templates/examples/home.html:5
  16
+msgid "Hello world"
  17
+msgstr ""
  18
+
  19
+#. This is a localizer comment
  20
+#: apps/examples/templates/examples/home.html:9
  21
+msgid "This is a <em>test view</em>."
  22
+msgstr ""
  23
+
  24
+#: apps/examples/templates/examples/home.html:11
  25
+msgid ""
  26
+"<a href=\"%(docs_url)s\">Learn you some Playdoh</a> and then go build "
  27
+"something <strong>awesome</strong>."
  28
+msgstr ""
  29
+
  30
+#: apps/examples/templates/examples/home.html:17
  31
+msgid "Current locale: %(LANG)s.<br> Available locales: %(langs)s."
  32
+msgstr ""

0 notes on commit b1122b4

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