Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
tellnes committed Nov 29, 2014
1 parent 15bd888 commit 7dd83ba
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
33 changes: 33 additions & 0 deletions example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
LANGUAGES = en nb

FILES = entry.js

PO_FILES = $(LANGUAGES:%=local/%.po)

BUILD_LANG ?= en

all: bundle.js

bundle.js: $(FILES) local/$(BUILD_LANG).po
browserify -t [jedify -l $(BUILD_LANG)] entry.js > bundle.js

messages.po: $(FILES)
xgettext \
$(FILES) \
--output messages.po \
--language python \
--omit-header \
--keyword=_p:1,2 \

local/:
test -d local || mkdir local

$(PO_FILES): messages.po local/
touch $@
msgmerge --lang $(basename $(notdir $@)) $@ messages.po --update

clean:
rm messages.po
rm bundle.js

.PHONY: all clean
5 changes: 5 additions & 0 deletions example/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var i18n = requirePo('./local/%s.po')

var _ = i18n.gettext.bind(i18n)

console.log(_('Hello World'))
22 changes: 22 additions & 0 deletions example/local/en.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-11-29 19:26+0100\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"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: entry.js:5
msgid "Hello World"
msgstr ""
22 changes: 22 additions & 0 deletions example/local/nb.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-11-29 19:26+0100\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"
"Language: nb\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: entry.js:5
msgid "Hello World"
msgstr ""
1 change: 1 addition & 0 deletions example/node_modules/jedify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7dd83ba

Please sign in to comment.