You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mi...@apache.org on 2013/04/29 12:01:23 UTC

git commit: updated refs/heads/master to 509cfa9

Updated Branches:
  refs/heads/master 766b36f57 -> 509cfa985


CLOUDSTACK-2138 - add a sync-transifex-ui.sh script to automate the exchange between CloudStack L10N resource files and Transifex CS-UI resource files

Signed-off-by: Milamber <mi...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/509cfa98
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/509cfa98
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/509cfa98

Branch: refs/heads/master
Commit: 509cfa98567f3d64b6da8bcb50c3d18e6d2bc122
Parents: 766b36f
Author: Milamber <mi...@apache.org>
Authored: Mon Apr 29 11:00:48 2013 +0100
Committer: Milamber <mi...@apache.org>
Committed: Mon Apr 29 11:02:26 2013 +0100

----------------------------------------------------------------------
 tools/transifex/.tx/config           |   19 ++++
 tools/transifex/README-transifex.txt |   65 ++++++++++++
 tools/transifex/sync-transifex-ui.sh |  158 +++++++++++++++++++++++++++++
 3 files changed, 242 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/509cfa98/tools/transifex/.tx/config
----------------------------------------------------------------------
diff --git a/tools/transifex/.tx/config b/tools/transifex/.tx/config
new file mode 100644
index 0000000..171d9b1
--- /dev/null
+++ b/tools/transifex/.tx/config
@@ -0,0 +1,19 @@
+[main]
+host = https://www.transifex.com
+
+[CloudStack_UI.2-2messagesproperties]
+file_filter = translations/CloudStack_UI.2-2messagesproperties/<lang>.properties
+source_lang = en
+
+[CloudStack_UI.30xmessagesproperties]
+file_filter = translations/CloudStack_UI.30xmessagesproperties/<lang>.properties
+source_lang = en
+
+[CloudStack_UI.41xmessageproperties]
+file_filter = translations/CloudStack_UI.41xmessageproperties/<lang>.properties
+source_lang = en
+
+[CloudStack_UI.42xmessagesproperties]
+file_filter = translations/CloudStack_UI.42xmessagesproperties/<lang>.properties
+source_lang = en
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/509cfa98/tools/transifex/README-transifex.txt
----------------------------------------------------------------------
diff --git a/tools/transifex/README-transifex.txt b/tools/transifex/README-transifex.txt
new file mode 100644
index 0000000..986aed7
--- /dev/null
+++ b/tools/transifex/README-transifex.txt
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+sync-transifex-ui is a script to automate the synchronisation between
+Apache CloudStack L10N resource files and Transifex CloudStack project.
+
+Commun usage is:
+
+1/ Init and configure the transifex client CLI
+(Already made on git CloudStack repo)
+
+  ./sync-transifex-ui.sh init-transifex https://www.transifex.com/projects/p/CloudStack_UI/
+
+2/ Upload to Transifex the last version of the source language (en)
+which generally have the new keys/values to translate.
+
+ ./sync-transifex-ui.sh upload-source-language CloudStack_UI.42xmessagesproperties
+
+3/ Download the last L10N resource files from Transifex to resources
+files directory in CloudStack tree to upade the L10N resource files
+with the translatons from traductors.
+
+ ./sync-transifex-ui.sh download-l10n-languages CloudStack_UI.42xmessagesproperties
+
+=====
+The sync-transifex-ui provide too the ability to :
+
+* Download from Transifex the source language resource files. Be carrefully, 
+with this,you can remove some transation on Transifex if some keys has 
+been removed inside the source language resource files.
+
+ ./sync-transifex-ui.sh download-source-language CloudStack_UI.42xmessagesproperties
+
+* Upload the L10N resource files on Transifex. 
+
+ ./sync-transifex-ui.sh upload-l10n-languages CloudStack_UI.42xmessagesproperties
+
+=====
+Note 1: 
+Choose the good branch on git matching with the good resource on Transifex:
+(no branch) <--> CloudStack_UI.2-2messagesproperties
+(no branch) <--> CloudStack_UI.30xmessagesproperties
+(4.1)       <--> CloudStack_UI.41xmessageproperties
+(master)    <--> CloudStack_UI.42xmessagesproperties
+
+Note 2:
+If you want add a new L10N language, we need edit the sync-transifex-ui.sh script
+to add his language code in LIST_LANG variable, before run the download-l10n-languages
+command.
+
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/509cfa98/tools/transifex/sync-transifex-ui.sh
----------------------------------------------------------------------
diff --git a/tools/transifex/sync-transifex-ui.sh b/tools/transifex/sync-transifex-ui.sh
new file mode 100755
index 0000000..5fb4e57
--- /dev/null
+++ b/tools/transifex/sync-transifex-ui.sh
@@ -0,0 +1,158 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+SRCLANG=en
+LIST_LANG="ca de_DE es fr_FR it_IT ja ko_KR nb_NO pt_BR ru_RU zh_CN"
+
+DIRECTORY_RESOURCES="../../client/WEB-INF/classes/resources"
+WORKDIR="./work-dir"
+
+AL2_STRING="# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n"
+
+doInit()
+{
+        tx init
+        tx set --auto-remote ${ARGUMENTS}
+}
+
+doMakeWdir()
+{
+        mkdir -p ${WORKDIR}
+}
+
+doCheckInit()
+{
+        if [ ! -f ./.tx/config ]; then
+                echo "Error: Transifex project isn't init. Please run $0 init-transifex URL-transifex-project" >&2
+                exit 2
+        fi
+}
+
+doUploadL10NLangs()
+{
+        # l10n languages
+        for CODELANG in ${LIST_LANG} ; do
+                if [ -f "${DIRECTORY_RESOURCES}/messages_${CODELANG}.properties" ]; then
+                        native2ascii -reverse -encoding UTF-8 ${DIRECTORY_RESOURCES}/messages_${CODELANG}.properties ${WORKDIR}/messages_${CODELANG}.properties
+                        sed -i "s/\\\\\\\'/'/g" ${WORKDIR}/messages_${CODELANG}.properties
+        		tx set -r ${ARGUMENTS} -l ${CODELANG} ${WORKDIR}/messages_${CODELANG}.properties
+                        tx push -t -r ${ARGUMENTS} -l ${CODELANG}
+                else   
+                        echo "Warning: the resource file for language ${CODELANG} doesn't exist."
+                fi
+        done
+}
+
+doDownloadL10NLangs()
+{
+        # prepare l10n languages
+        for CODELANG in ${LIST_LANG} ; do
+                if [ -f "${DIRECTORY_RESOURCES}/messages_${CODELANG}.properties" ]; then
+                        native2ascii -reverse -encoding UTF-8 ${DIRECTORY_RESOURCES}/messages_${CODELANG}.properties ${WORKDIR}/messages_${CODELANG}.properties
+                        sed -i "s/\\\\\\\'/'/g" ${WORKDIR}/messages_${CODELANG}.properties
+        		tx set -r ${ARGUMENTS} -l ${CODELANG} ${WORKDIR}/messages_${CODELANG}.properties
+                else   
+                        echo "Warning: the resource file for language ${CODELANG} doesn't exist."
+                fi
+        done
+
+        # get all resource files from transifex
+        tx pull -r ${ARGUMENTS} 
+
+        # l10n languages
+        for CODELANG in ${LIST_LANG} ; do
+                #tx pull -r ${ARGUMENTS} -l ${CODELANG}
+                if [ -f "${WORKDIR}/messages_${CODELANG}.properties" ]; then
+                        native2ascii -encoding UTF-8 ${WORKDIR}/messages_${CODELANG}.properties ${WORKDIR}/messages_${CODELANG}.properties.tmp1
+                        grep -v "^#" ${WORKDIR}/messages_${CODELANG}.properties.tmp1 | sort -f | uniq | sed "s/'/\\\\\\\\\'/g" > ${WORKDIR}/messages_${CODELANG}.properties.tmp2
+                        echo "$AL2_STRING" | cat - ${WORKDIR}/messages_${CODELANG}.properties.tmp2 > ${DIRECTORY_RESOURCES}/messages_${CODELANG}.properties
+                else   
+                        echo "Warning: the resource file for language ${CODELANG} doesn't exist on transifex"
+                fi
+        done
+}
+
+doUploadSourceLang()
+{
+        # Source language
+        if [ -f ${DIRECTORY_RESOURCES}/messages.properties ]; then
+                native2ascii -reverse -encoding UTF-8 ${DIRECTORY_RESOURCES}/messages.properties ${WORKDIR}/messages.properties
+                sed -i "s/\\\\\\\'/'/g" ${WORKDIR}/messages.properties
+                tx set --source -r ${ARGUMENTS} -l ${SRCLANG} ${WORKDIR}/messages.properties
+                tx push -s -r ${ARGUMENTS} 
+        else
+		echo "Warning: the source language doesn't exist!"
+        fi
+}
+
+doDownloadSourceLang()
+{
+        # get all resource files from transifex
+        tx pull -s -r ${ARGUMENTS} 
+        # Source language
+        if [ -f "${WORKDIR}/messages.properties" ]; then
+                native2ascii -encoding UTF-8 ${WORKDIR}/messages.properties ${WORKDIR}/messages.properties.tmp1
+                grep -v "^#" ${WORKDIR}/messages.properties.tmp1 | sort -f | uniq | sed "s/'/\\\\\\\\\'/g" > ${WORKDIR}/messages.properties.tmp2
+                echo "$AL2_STRING" | cat - ${WORKDIR}/messages.properties.tmp2 > ${DIRECTORY_RESOURCES}/messages.properties
+        else
+		echo "Warning: the source language hasn't been retrieve!"
+	fi
+}
+
+if [ $# -ne 2 ]; then
+        COMMAND="error"
+else
+        COMMAND="$1"
+        ARGUMENTS="$2"
+	doMakeWdir
+fi
+
+case "$COMMAND" in
+        upload-source-language)
+                doCheckInit
+                doUploadSourceLang
+                ;;
+
+        download-source-language)
+                doCheckInit
+                doDownloadSourceLang
+                ;;
+
+        upload-l10n-languages)
+                doCheckInit
+                doUploadL10NLangs
+                ;;
+
+        download-l10n-languages)
+                doCheckInit
+                doDownloadL10NLangs
+                ;;
+
+        init-transifex)
+                doInit
+                ;;
+
+        *|error)
+                echo "Usage: $0 [upload-source-language|download-source-language] [upload-l10n-languages|download-l10n-languages] transifex-resource" >&2
+                echo "\n\tExemple: $0 download-l10n-languages CloudStack_UI-42xmessagesproperties\n" >&2
+                echo "Usage: $0 init-transifex URL-transifex-project" >&2
+                echo "\n\tExemple: $0 init-transifex https://www.transifex.com/projects/p/CloudStack_UI/\n" >&2
+                exit 1
+                ;;
+esac
+