cancel
Showing results for 
Search instead for 
Did you mean: 

Tools for translators

kevinr
Star Contributor
Star Contributor
Tools for translators

Jérôme Baton (jbaton) has kindly provided a helpful tool to compare properties files. This makes it easy to see what strings have been added, removed and changes between versions of Alfresco. Hopefully this should make it a far less painful process when we release new versions! Smiley Happy

It can be downloaded from sourceforge as usual:
http://sourceforge.net/projects/alfresco
or more directly:
http://sourceforge.net/project/showfiles.php?group_id=143373&package_id=162536

You may also like this tool https://prbeditor.dev.java.net/
It allows a user to modify all the registered bundles with a Swing editor. More useful in a context where one person translates several bundles.

Thanks,

Kevin
4 REPLIES 4

lgr
Champ in-the-making
Champ in-the-making
Hi,

A small tool for unix guys (or users using unix under win32), which is also useful :
it creates a file containing all messages :
- as is if unmodified since last version
- the old version messages prefixed with "##oldEN#" if the messages have changed since last version
- the modified messages since last version, prefixed with "##newEN#"
- the old version of the translated message file prefixed with "##oldTR#"

[12/20/2005: Edited to ease its use]
To use it :
- launch the script with arguments :
 
    - EN message file path in the old version (including filename)
      - EN message file path in the new version (including filename)
      - translated message file path in the old version (including filename)
- edit the new generated file (the 4th variable), search for "##" and translate messages.

Usage example :
./script.sh webclient.properties-v11 webclient.properties-v111 webclient_fr_FR.properties-v11 webclient_fr_FR.properties-v111

Notice that all messages are in the correct order : you obtain the new language file, ready for working on new or modified items. No need to find the old modified items with a text editor, two windows, or such heavy processes.

Hope this helps,

Laurent.

PS : there is a bug in messages files (cf post http://www.alfresco.org/forums/viewtopic.php?p=1990&sid=c2cfbd518fb6afc58b26a712fc701eb3#1990), so some messages are written many times. You can fix it wether by patching yourself the Alfresco messages files, or by adding a "|uniq" in the line
grep ^${FIELD}= $TRANSLATED_FILE |uniq >> $DST_FILE
, or a "head -n 1". To know it there are some duplicated messages, launch a
cat yourfile.properties |cut -d= -f1|sort |uniq -c|grep -v "     1 "
.



#!/bin/sh

usage()
{
    echo "Usage : $0 old_EN_Message_file New_EN_Message_file Old_translated_Message_file Output_file"
    exit 1
}

if [ $# -lt 4 ]; then
    usage
fi

OLD_EN_FILE=$1
NEW_EN_FILE=$2
TRANSLATED_FILE=$3
DST_FILE=$4
# temp file, deleted at the end
TMP_FILE=all_terms

#Find all modified messages
diff $OLD_EN_FILE $NEW_EN_FILE |awk '{print $2}' |cut -d= -f1 |sort -u|grep -v "^#"|grep -v "^\$" > $TMP_FILE

put_message()
{
    TMPSTR=`grep ^${1}= $2`
    if [ \! -z "$TMPSTR" ]; then
        echo "##$3#$TMPSTR" >> $DST_FILE
    fi
}

#Parse each line from the new EN message file
cat $NEW_EN_FILE | while read line; do
#If the line is not a message, put it in the new file
    if [ "X`echo $line |grep =`" = "X" ]; then
        echo "$line" >> $DST_FILE
    else
        FIELD=`echo $line|cut -d= -f1`
#If the line contains a message which is unmodified since last version, put it in the new file
        if [ "X`grep ^${FIELD}\$ $TMP_FILE`" = "X" ]; then
            grep ^${FIELD}= $TRANSLATED_FILE |uniq >> $DST_FILE
        else
#If the line contains a message modified since last version, then
#Put the old translated message if not empty
            put_message $FIELD $TRANSLATED_FILE "oldTR"
#Then Put the old EN message if not empty (to compare old and new EN message)
            put_message $FIELD $OLD_EN_FILE "oldEN"
#Then put the new message
            put_message $FIELD $NEW_EN_FILE "newEN"
        fi
    fi
done

rm $TMP_FILE

An example with my french translated file :
title_export=Export
title_import=Import
##oldTR#title_admin_store_browser=Administration du navigateur d'Espaces
##oldEN#title_admin_store_browser=Admin Store Browser
##newEN#title_admin_store_browser=Alfresco Store Browser
##oldTR#title_admin_node_browser=Administration du navigateur d'\u00e9l\u00e9ments
##oldEN#title_admin_node_browser=Admin Node Browser
##newEN#title_admin_node_browser=Alfresco Node Browser
##oldTR#title_admin_search_results=Administration des r\u00e9sultats de recherche
##oldEN#title_admin_search_results=Admin Search Results
##newEN#title_admin_search_results=Node Browser Search Results
##newEN#title_forums=Forums
##newEN#title_forum=Forum

"title_forum" message has been added.
"title_admin_search_results" message has been modified, you'll find the old EN and the new EN version with your translated old version.
"title_export" message has not been modified.
If you find "oldEN" and "oldTR" messages and no "newEN" message, that seems that the message has been removed.

jbaton
Champ in-the-making
Champ in-the-making
Hi all,

The tool provided is an ANT task.
Therefore the ANT library is needed to use it , and of course, Java.

It loads two .properties files, compares the keys and reports the keys present and absent, in file 1 and file 2

Simple, useful and easy (well if you have the platform to run it Smiley Happy  ) 

Translators should use it in this way.

Let's consider the EN bundle is the reference.

For example, as when release X.X is out, a translator should use the tool to compare EN-X.X (say file1) files with his latest translated bundle (say file2)

The result will be the list of :
* new keys (present in file1 , absent in file2)
* keys that are not used anymore (present in file2 , absent in file1)

Add new keys, remove unused ones. Then fill the blanks.
And you are done !

Hope it helps

Congrats to lgr for the script !

Jérôme BATON
http://www.wadael.org

sebek72
Champ in-the-making
Champ in-the-making
This script works pretty well, but it does not add all missing lines.

I have old 3.2 english (V1), new 3.3 english (V2), old 3.2 my lang translation (v3).

When i run this script a new file is successfully created (V4), but a lot of lines are missing.

example;
V1 - 2074 lines
V2 - 2123 lines
V3 - 1574 lines (it's not  a full translation)
V4 - 1756 lines (it adds some lines, but not nearly enough) - a lof of strings are missing.

Any clues how to fix this?

Thank you

sebek72
Champ in-the-making
Champ in-the-making
Found out that the problem occurs when oldTR file doesn't contain translation, but is in both oldEN and newEN files.