33BUILD_DATE = $(shell date "+% Y/% m/% d % H:% M:% S")
44COMMON_DIR = ../common
55
6- LOCALEDIR = locale
7- ifeq ($(LOCALE ) ,)
8- LOCALEDIR = locale/en-US
9- else
10- LOCALEDIR = locale/en-US locale/$(LOCALE)
11- endif
12- DOC_FILES = $(foreach dir,$(LOCALEDIR ) ,$(wildcard $(dir ) /* .xml) )
6+ DOC_FILES = $(foreach dir,locale/en-US,$(wildcard $(dir ) /* .xml) )
137
148XPI_FILES = install.rdf TODO AUTHORS NEWS chrome.manifest ../License.txt
159XPI_DIRS = components $(COMMON_DIR ) /components
2620 XPI_FILE = downloads/$(XPI_NAME).xpi
2721endif
2822
23+ # ## Locales
24+ L1 = $(shell ls locale)
25+ L2 = $(shell ls ../common/locale)
26+ L1_LEN = $(shell echo $(L1 ) | wc -c)
27+ L2_LEN = $(shell echo $(L2 ) | wc -c)
28+ OPTION = $(shell test $(L1_LEN ) -gt $(L2_LEN ) && echo 1)
29+
30+ ifeq ($(OPTION ) ,1)
31+ SUPPORTED_LOCALES = $(L1)
32+ else
33+ SUPPORTED_LOCALES = $(L2)
34+ endif
35+
36+ LOCALE_MAP = . locale $(NAME ) \n.. common/locale liberator\n
37+
2938.SILENT :
3039
3140# ### rules
@@ -45,13 +54,12 @@ help:
4554 @echo " make info - show some info about the system"
4655 @echo " make xpi - build an XPI ($( XPI_NAME) )"
4756 @echo " make clean - clean up"
48- @echo
49- @echo " running some commands with V=1 will show more build details"
5057
5158info :
5259 @echo " version $( VERSION) "
5360 @echo " release file $( XPI) "
5461 @echo " doc files $( DOC_FILES) "
62+ @echo " supported locales $( SUPPORTED_LOCALES) "
5563 @echo " xpi files $( XPI_FILES) "
5664
5765clean :
6775 # Copy top level files
6876 cp -L $(XPI_FILES) $(XPI_PATH)
6977
70- @echo "Update chrome.manifest for paths used inside the XPI..."
71- sed -i -e 's# ../common/#common/#' $(XPI_PATH)/chrome.manifest
72-
73- if [ "x$(LOCALE)" != "x" ]; then \
74- echo "locale $(NAME) $(LOCALE) locale/$(LOCALE)/" >> $(XPI_PATH)/chrome.manifest; \
75- echo "locale liberator $(LOCALE) common/locale/$(LOCALE)/" >> $(XPI_PATH)/chrome.manifest; \
76- fi
77-
7878 # Copy components and modules directories
7979 cp -LR $(XPI_DIRS) $(XPI_PATH)
8080
8181 # Copy all chrome files from commmon/ folder
8282 cd $(COMMON_DIR) && \
83- cp -LR $(COMMON_CHROME_DIRS) $(XPI_PATH)/common && \
84- cp -LR $(LOCALEDIR) $(XPI_PATH)/common/locale || true
83+ cp -LR $(COMMON_CHROME_DIRS) $(XPI_PATH)/common
8584
8685 # Copy all chrome files from vimperator|muttator folder
8786 cp -LR $(CHROME_DIRS) $(XPI_PATH)
88- cp -LR $(LOCALEDIR) $(XPI_PATH)/locale || true
87+
88+ # Remove existing locale entries from the manifest file
89+ for locale in $(SUPPORTED_LOCALES); do \
90+ sed -i -e "/$$locale/d" $(XPI_PATH)/chrome.manifest; \
91+ done
92+
93+ # Package up locale specific documentation files
94+ # * Create a folder for the requested locale in the build directory
95+ # * Copy the English version of the documentation files there
96+ # * Overwrite them with documentation files from the requested locale
97+ # * Add an entry for the requested locale in the chrome.manifest file
98+ for locale in $(SUPPORTED_LOCALES); do \
99+ echo "Including $$locale documentation"; \
100+ printf "$(LOCALE_MAP)" | \
101+ while read parent dir name; do\
102+ src=$$parent/$$dir/$$locale; \
103+ dest=$(XPI_PATH)/$$dir/$$locale; \
104+ mkdir -p $$dest; \
105+ cp -LR $$parent/$$dir/en-US/. $$dest; \
106+ test -d $$src && \
107+ cp -LR $$src/. $$dest; \
108+ echo "locale $$name $$locale $$dir/$$locale/" >> $(XPI_PATH)/chrome.manifest; \
109+ done;\
110+ done
111+
112+ # Update locale paths in manifest file
113+ sed -i -e 's# ./locale/# locale/#' $(XPI_PATH)/chrome.manifest
114+ sed -i -e 's# ../common/#common/#' $(XPI_PATH)/chrome.manifest
89115
90116 @echo "Replacing # ##VERSION### and ###DATE### tags"
91117 for file in `grep -rl -e "# ##VERSION###" -e "###DATE###" $(XPI_PATH)`; do \
124150 rm -rf ../downloads/common
125151
126152 @echo "SUCCESS: $(XPI_FILE)"
127-
0 commit comments