Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Commit

Permalink
Add an example locale/ directory
Browse files Browse the repository at this point in the history
  • Loading branch information
stasm committed Jun 10, 2011
1 parent 9908571 commit b1122b4
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -14,4 +14,4 @@ vendor
.noseids .noseids
tmp/* tmp/*
*~ *~
locale/* *.mo
37 changes: 0 additions & 37 deletions bin/autol10n.sh

This file was deleted.

19 changes: 14 additions & 5 deletions bin/compile-mo.sh
@@ -1,19 +1,28 @@
#!/bin/bash #!/bin/bash


# syntax: TARGET=$1
# compile-mo.sh locale-dir/ LOCKFILE="/tmp/compile-mo-${2}.lock"


function usage() { function usage() {
echo "syntax:" echo "syntax:"
echo "compile.sh locale-dir/" echo " compile-mo.sh locale-dir/ [unique]"
echo "unique is an optional string that will be used as the name of the lockfile"
exit 1 exit 1
} }


# check if file and dir are there # check if file and dir are there
if [[ ($# -ne 1) || (! -d "$1") ]]; then usage; fi if [[ ($# -gt 2) || (! -d "$TARGET") ]]; then usage; fi


for lang in `find $1 -type f -name "*.po"`; do # check if the lockfile exists
if [ -e $LOCKFILE ]; then
echo "$LOCKFILE present, exiting"
exit 99
fi

touch $LOCKFILE
for lang in `find $TARGET -type f -name "*.po"`; do
dir=`dirname $lang` dir=`dirname $lang`
stem=`basename $lang .po` stem=`basename $lang .po`
msgfmt -o ${dir}/${stem}.mo $lang msgfmt -o ${dir}/${stem}.mo $lang
done done
rm $LOCKFILE
29 changes: 23 additions & 6 deletions bin/update_site.py 100644 → 100755
Expand Up @@ -16,6 +16,7 @@
import sys import sys
from textwrap import dedent from textwrap import dedent
from optparse import OptionParser from optparse import OptionParser
from hashlib import md5


# Constants # Constants
PROJECT = 0 PROJECT = 0
Expand All @@ -28,10 +29,17 @@
'prod': ['prod', 'master'], 'prod': ['prod', 'master'],
} }


# The URL of the SVN repository with the localization files (*.po). If you set
# it to a non-empty value, remember to `git rm --cached -r locale` in the root
# of the project. Example:
# LOCALE_REPO_URL = 'https://svn.mozilla.org/projects/l10n-misc/trunk/playdoh/locale'
LOCALE_REPO_URL = ''

GIT_PULL = "git pull -q origin %(branch)s" GIT_PULL = "git pull -q origin %(branch)s"
GIT_SUBMODULE = "git submodule update --init" GIT_SUBMODULE = "git submodule update --init"
SVN_CO = "svn checkout --force %(url)s locale"
SVN_UP = "svn update" SVN_UP = "svn update"
COMPILE_PO = "./compile.sh" COMPILE_MO = "./bin/compile-mo.sh %(localedir)s %(unique)s"


EXEC = 'exec' EXEC = 'exec'
CHDIR = 'chdir' CHDIR = 'chdir'
Expand All @@ -41,6 +49,8 @@ def update_site(env, debug):
"""Run through commands to update this site.""" """Run through commands to update this site."""
error_updating = False error_updating = False
here = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) here = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
locale = os.path.join(here, 'locale')
unique = md5(locale).hexdigest()
project_branch = {'branch': ENV_BRANCH[env][PROJECT]} project_branch = {'branch': ENV_BRANCH[env][PROJECT]}
vendor_branch = {'branch': ENV_BRANCH[env][VENDOR]} vendor_branch = {'branch': ENV_BRANCH[env][VENDOR]}


Expand All @@ -50,17 +60,24 @@ def update_site(env, debug):
(EXEC, GIT_SUBMODULE), (EXEC, GIT_SUBMODULE),
] ]


# Checkout the locale repo into locale/ if the URL is known
if LOCALE_REPO_URL and not os.path.exists(os.path.join(locale, '.svn')):
commands += [
(EXEC, SVN_CO % {'url': LOCALE_REPO_URL}),
(EXEC, COMPILE_MO % {'localedir': locale, 'unique': unique}),
]

# Update locale dir if applicable # Update locale dir if applicable
if os.path.exists(os.path.join(here, 'locale', '.svn')): if os.path.exists(os.path.join(locale, '.svn')):
commands += [ commands += [
(CHDIR, os.path.join(here, 'locale')), (CHDIR, locale),
(EXEC, SVN_UP), (EXEC, SVN_UP),
(EXEC, COMPILE_PO),
(CHDIR, here), (CHDIR, here),
(EXEC, COMPILE_MO % {'localedir': locale, 'unique': unique}),
] ]
elif os.path.exists(os.path.join(here, 'locale', '.git')): elif os.path.exists(os.path.join(locale, '.git')):
commands += [ commands += [
(CHDIR, os.path.join(here, 'locale')), (CHDIR, locale),
(EXEC, GIT_PULL % 'master'), (EXEC, GIT_PULL % 'master'),
(CHDIR, here), (CHDIR, here),
] ]
Expand Down
31 changes: 31 additions & 0 deletions locale/en_US/LC_MESSAGES/messages.po
@@ -0,0 +1,31 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-05-26 18:11-0700\n"
"PO-Revision-Date: 2011-05-26 18:11-0700\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.8.0\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: apps/examples/templates/examples/home.html:5
msgid "Hello world"
msgstr "Hello world"

#. This is a localizer comment
#: apps/examples/templates/examples/home.html:9
msgid "This is a <em>test view</em>."
msgstr "This is a <em>test view</em>."

#: apps/examples/templates/examples/home.html:11
msgid "<a href=\"%(docs_url)s\">Learn you some Playdoh</a> and then go build something <strong>awesome</strong>."
msgstr "<a href=\"%(docs_url)s\">Learn you some Playdoh</a> and then go build something <strong>awesome</strong>."

#: apps/examples/templates/examples/home.html:17
msgid "Current locale: %(LANG)s.<br> Available locales: %(langs)s."
msgstr "Current locale: %(LANG)s.<br> Available locales: %(langs)s."
29 changes: 29 additions & 0 deletions locale/fr/LC_MESSAGES/messages.po
@@ -0,0 +1,29 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-06-03 19:07-0700\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#: apps/examples/templates/examples/home.html:5
msgid "Hello world"
msgstr "Bonjour le monde"

#. This is a localizer comment
#: apps/examples/templates/examples/home.html:9
msgid "This is a <em>test view</em>."
msgstr "Ceci est une <em>vue de test</em>."

#: apps/examples/templates/examples/home.html:11
msgid "<a href=\"%(docs_url)s\">Learn you some Playdoh</a> and then go build something <strong>awesome</strong>."
msgstr "<a href=\"%(docs_url)s\">Apprends à jouer avec Playdoh</a> et construis quelque chose de <strong>génial</strong>."

#: apps/examples/templates/examples/home.html:17
msgid "Current locale: %(LANG)s.<br> Available locales: %(langs)s."
msgstr "Langue active&nbsp;: %(LANG)s.<br> Langues disponibles&nbsp;: %(langs)s."
32 changes: 32 additions & 0 deletions locale/templates/LC_MESSAGES/messages.pot
@@ -0,0 +1,32 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-06-03 19:07-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.8.0\n"

#: apps/examples/templates/examples/home.html:5
msgid "Hello world"
msgstr ""

#. This is a localizer comment
#: apps/examples/templates/examples/home.html:9
msgid "This is a <em>test view</em>."
msgstr ""

#: apps/examples/templates/examples/home.html:11
msgid ""
"<a href=\"%(docs_url)s\">Learn you some Playdoh</a> and then go build "
"something <strong>awesome</strong>."
msgstr ""

#: apps/examples/templates/examples/home.html:17
msgid "Current locale: %(LANG)s.<br> Available locales: %(langs)s."
msgstr ""

0 comments on commit b1122b4

Please sign in to comment.