Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding '{{ LANGUAGE_CODE }}' replacement. Closes #3

  • Loading branch information...
commit 17b9a94c2468b51be79fa89c47b5330d635cb72b 1 parent 37aaa9c
@mikewest authored
View
2  example/build/de_DE/index.html
@@ -1,5 +1,5 @@
<!doctype html>
-<html lang="de">
+<html lang="de-de">
<head>
<title>Hallo Welt!</title>
</head>
View
2  example/build/en_US/index.html
@@ -1,5 +1,5 @@
<!doctype html>
-<html lang="en">
+<html lang="en-us">
<head>
<title>Hello, world!</title>
</head>
View
BIN  example/locale/de_DE/LC_MESSAGES/messages.mo
Binary file not shown
View
6 example/locale/de_DE/LC_MESSAGES/messages.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-09-12 17:13+0200\n"
+"POT-Creation-Date: 2010-10-03 09:33+0200\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"
@@ -17,10 +17,6 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: src/index.html:2
-msgid "en"
-msgstr "de"
-
#: src/index.html:4
msgid "Hello, world!"
msgstr "Hallo Welt!"
View
BIN  example/locale/en_US/LC_MESSAGES/messages.mo
Binary file not shown
View
6 example/locale/en_US/LC_MESSAGES/messages.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-09-12 17:13+0200\n"
+"POT-Creation-Date: 2010-10-03 09:33+0200\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"
@@ -17,10 +17,6 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: src/index.html:2
-msgid "en"
-msgstr ""
-
#: src/index.html:4
msgid "Hello, world!"
msgstr ""
View
2  example/src/index.html
@@ -1,5 +1,5 @@
<!doctype html>
-<html lang="{% blocktrans %}en{% endblocktrans %}">
+<html lang="{{ LANGUAGE_CODE }}">
<head>
<title>{% blocktrans %}Hello, world!{% endblocktrans %}</title>
</head>
View
19 static_gettext.py
@@ -1,6 +1,21 @@
#!/usr/bin/env python
# encoding: utf-8;
+###########################################################################
+#
+# static_gettext: Localization for static documents
+# http://projects.mikewest.org/static_gettext/
+#
+# Version: 0.11
+#
+# static_gettext is an internationalization framework for static,
+# plaintext documents and templates. It’s geared towards straightforward
+# translation of static websites, but can be easily used for any set of
+# files you’d like to translate as a group.
+#
+# (c)2010 Mike West, BSD licensed ( http://github.com/mikewest/static_gettext/blob/master/LICENSE.markdown )
+#
+
from __future__ import with_statement
import re, os, sys
@@ -107,6 +122,10 @@ def puttextize( self, file, locale ):
basename, extension = os.path.splitext( file )
if extension in self.extensions:
src = self.templatize( file=file, type=Localizer.PUTTEXT, locale=locale, l10n=l10n )
+
+ # Replace `{{ LANGUAGE_CODE }}` with a BCP47 language tag
+ src = src.replace( r'{{ LANGUAGE_CODE }}', locale.lower().replace( '_', '-' ) )
+
with open( outfile, 'wb' ) as f:
f.write( src.encode( 'utf-8' ) )
else:
Please sign in to comment.
Something went wrong with that request. Please try again.