Commit
…lient-l10n directory
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,21 +179,37 @@ $(BUILT)/ui/%.js: ui/%.jsx | |
# standalone | ||
standalone_jsx_files=$(wildcard standalone/content/js/*.jsx) | ||
built_standalone_js_files=$(standalone_jsx_files:%.jsx=$(BUILT)/%.js) | ||
standalone_l10n_files=$(wildcard locale/*/standalone.properties) | ||
built_standalone_l10n_files=$(patsubst locale/%/standalone.properties, \ | ||
$(BUILT)/standalone/content/l10n/%/loop.properties, \ | ||
$(standalone_l10n_files)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Mardak
Author
Owner
|
||
|
||
$(BUILT)/standalone/content/js/%.js: standalone/content/js/%.jsx | ||
@mkdir -p $(@D) | ||
$(BABEL) $< --out-file $@ | ||
|
||
$(BUILT)/standalone/content/l10n/%/loop.properties: locale/%/standalone.properties locale/%/shared.properties | ||
@mkdir -p $(@D) | ||
cat $^ > $@ | ||
This comment has been minimized.
Sorry, something went wrong.
dmose
|
||
|
||
# add-on | ||
add_on_jsx_files=$(wildcard add-on/panels/js/*.jsx) | ||
built_add_on_js_files=$(patsubst add-on/panels/js/%.jsx, \ | ||
$(BUILT)/add-on/chrome/content/panels/js/%.js, \ | ||
$(add_on_jsx_files)) | ||
add_on_l10n_files=$(wildcard locale/*/add-on.properties) | ||
built_add_on_l10n_files=$(patsubst locale/%/add-on.properties, \ | ||
$(BUILT)/add-on/chrome/locale/%/loop.properties, \ | ||
$(add_on_l10n_files)) | ||
|
||
$(BUILT)/add-on/chrome/content/panels/js/%.js: add-on/panels/js/%.jsx | ||
@mkdir -p $(@D) | ||
$(BABEL) $< --out-file $@ | ||
|
||
$(BUILT)/add-on/chrome/locale/%/loop.properties: locale/%/add-on.properties locale/%/shared.properties | ||
@mkdir -p $(@D) | ||
cat $^ > $@ | ||
|
||
# XXX maybe just build one copy of shared in standalone, and then use | ||
# server.js magic to redirect? | ||
# XXX ecma3 transform for IE? | ||
|
@@ -205,16 +221,14 @@ ui: node_modules $(built_ui_js_files) $(built_ui_shared_js_files) | |
$(RSYNC) shared $(BUILT)/$@ | ||
|
||
.PHONY: standalone | ||
standalone: node_modules $(built_standalone_js_files) $(built_standalone_shared_js_files) | ||
standalone: node_modules $(built_standalone_js_files) $(built_standalone_shared_js_files) $(built_standalone_l10n_files) | ||
mkdir -p $(BUILT)/$@ | ||
$(RSYNC) $@ $(BUILT) | ||
mkdir -p $(BUILT)/$@/content/shared | ||
$(RSYNC) shared $(BUILT)/$@/content | ||
mkdir -p $(BUILT)/$@/content/l10n/en-US | ||
cat locale/en-US/$@.properties locale/en-US/shared.properties > $(BUILT)/$@/content/l10n/en-US/loop.properties | ||
|
||
.PHONY: add-on | ||
add-on: node_modules $(built_add_on_js_files) $(built_add_on_shared_js_files) $(BUILT)/$(ADD-ON)/chrome.manifest $(BUILT)/add-on/chrome/content/preferences/prefs.js | ||
add-on: node_modules $(built_add_on_js_files) $(built_add_on_shared_js_files) $(built_add_on_l10n_files) $(BUILT)/$(ADD-ON)/chrome.manifest $(BUILT)/add-on/chrome/content/preferences/prefs.js | ||
mkdir -p $(BUILT)/$@ | ||
$(RSYNC) $@/chrome/bootstrap.js $(BUILT)/$@ | ||
sed "s/@FIREFOX_VERSION@/$(FIREFOX_VERSION)/g" add-on/install.rdf.in | \ | ||
|
@@ -228,8 +242,6 @@ add-on: node_modules $(built_add_on_js_files) $(built_add_on_shared_js_files) $( | |
mkdir -p $(BUILT)/$@/chrome/content/shared | ||
$(RSYNC) shared $(BUILT)/$@/chrome/content | ||
$(RSYNC) $@/chrome/skin $(BUILT)/$@/chrome/ | ||
mkdir -p $(BUILT)/$@/chrome/locale/en-US | ||
cat locale/en-US/$@.properties locale/en-US/shared.properties > $(BUILT)/$@/chrome/locale/en-US/loop.properties | ||
|
||
$(BUILT)/$(ADD-ON)/chrome.manifest: $(ADD-ON)/jar.mn | ||
mkdir -p $(BUILT)/$(ADD-ON) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/python | ||
|
||
## | ||
# This script is designed to update the l10n files and locale registration for | ||
# the standalone loop client and loop add-on. The source of the localization | ||
# files is https://github.com/mozilla/loop-client-l10n repository. | ||
# The loop repo is assumed to be https://github.com/mozilla/loop. | ||
# | ||
# Run this script from the local version of loop. It assumes that a local | ||
# version of loop-client-l10n is in a parallel directory: ../loop-client-l10n. | ||
## | ||
|
||
from __future__ import print_function | ||
|
||
import argparse | ||
import io | ||
import os | ||
import re | ||
import shutil | ||
|
||
# defaults | ||
DEF_L10N_SRC = os.path.join(os.pardir, "loop-client-l10n", "l10n") | ||
DEF_L10N_DST = os.path.join("locale") | ||
DEF_INDEX_FILE_NAME = os.path.join("standalone", "content", os.extsep.join(["index", "html"])) | ||
DEF_JAR_FILE_NAME = os.path.join("add-on", os.extsep.join(["jar", "mn"])) | ||
|
||
|
||
def main(l10n_src, l10n_dst, index_file_name, jar_file_name): | ||
print("deleting existing l10n content tree:", l10n_dst) | ||
shutil.rmtree(l10n_dst, ignore_errors=True) | ||
|
||
print("updating l10n tree from", l10n_src) | ||
|
||
def create_locale(src_dir): | ||
# Convert loop-client-l10n repo names to loop repo names. | ||
dst_dir = src_dir.replace('_', '-').replace('templates', 'en-US') | ||
|
||
shutil.copytree(os.path.join(l10n_src, src_dir), os.path.join(l10n_dst, dst_dir)) | ||
return dst_dir | ||
|
||
locale_dirs = os.listdir(l10n_src) | ||
locale_list = sorted([create_locale(x) for x in locale_dirs if x[0] != "."]) | ||
|
||
print("updating locales list in", index_file_name) | ||
with io.open(index_file_name, "r+") as index_file: | ||
index_html = index_file.read() | ||
|
||
# Replace the one meta line with new locales. | ||
new_content = re.sub( | ||
'<meta name=(["|\'])locales\\1.*? content=(["|\']).*?\\2.*? />', | ||
'<meta name="locales" content="' + ",".join(locale_list) + '" />', | ||
index_html, 1, re.M | re.S) | ||
|
||
index_file.seek(0) | ||
index_file.truncate(0) | ||
index_file.write(new_content) | ||
|
||
print("updating locales list in", jar_file_name) | ||
with io.open(jar_file_name, "r+") as jar_file: | ||
jar_mn = jar_file.read() | ||
|
||
# Replace multiple locale registrations with new locales. | ||
jar_locales = ['% locale loop {0} %locale/{0}/'.format(x) for x in locale_list] | ||
new_content = re.sub( | ||
'(% locale loop .+\n)+', | ||
'\n'.join(jar_locales) + '\n', | ||
jar_mn) | ||
|
||
jar_file.seek(0) | ||
jar_file.truncate(0) | ||
jar_file.write(new_content) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description="Loop Stand-alone Client localization update script") | ||
parser.add_argument('--src', | ||
default=DEF_L10N_SRC, | ||
metavar="path", | ||
help="Source path for l10n resources. Default = " + DEF_L10N_SRC) | ||
parser.add_argument('--dst', | ||
default=DEF_L10N_DST, | ||
metavar="path", | ||
help="Destination path for l10n resources. Default = " + DEF_L10N_DST) | ||
parser.add_argument('--index-file', | ||
default=DEF_INDEX_FILE_NAME, | ||
metavar="name", | ||
help="File to be updated with the locales list. Default = " + DEF_INDEX_FILE_NAME) | ||
parser.add_argument('--jar-file', | ||
default=DEF_JAR_FILE_NAME, | ||
metavar="name", | ||
help="Jar file to be updated with the locales list. Default = " + DEF_JAR_FILE_NAME) | ||
args = parser.parse_args() | ||
main(args.src, args.dst, args.index_file, args.jar_file) |
I think this would be slightly more readable if you put these lines after the next target (ie the standalone JSX build target. Similar comment for the other added stanzas.