Skip to main content Help Control Panel

YACS CMS : Open source !

Community «   Discussion forum «   Localization support board «  

First tests of localizations have been positive

avatarBernard Paques -- on Oct. 29 2006, from nearby-an-airport
YACS Leader
Tonight I have localised one large script to validate the i18n/l10n approach for YACS. poEdit is great, and I believe many translators will have fun quite soon...

Some information related to this important change for YACS:

-  Every language will be supported through additional .mo files external to scripts.

-  All of these files will be easy to change and to adapt to specific needs where required.

-  YACS includes its own .mo reader, because of all servers that don't have gettext readily available...

-  The impact on response times has been minimized by spreading strings on several files, and by caching .mo content ... in PHP files where possible.

First real applications are planned for the version 6.10, due next week.
NickR
avatar
from West Yorkshire, UK
342 posts

on Oct. 30 2006


Cool,

So I can even customise the English text now ?

Nick
Vincent
avatar
from on-a-few-hops-from-you
20 posts

on Oct. 30 2006


Great! I see this is going on! Started out on my own, in bash, to translate this yacs, but this sounds way better.

Since i took some hurdles (read: welcome in qoute hell!) i like to share the script with you anyhow:

#!/bin/bash
#-------------------
# transyacs.sh
# a small script to help localize YACS and others who
# use 'the poor mans localization' method :)
# run in the top-level directory, you will get an extra file
# for each translation, like: about.php and about.php_nl
#
#
# unpack the yacs zip file, cd to it and run this script
# translate, and send back in!
#
# share and enjoy!
#
# Vincent Kersten, GPLv2 licence, vince(a)puscii(dot)nl
# http://www.latinovac.org/ (no yacs yet! booh!)
#------------------

# the only thing to change in the script:
translate_to=\"nl\" # language you want to
# translate to
# use two letter codes

translate_from=\"en\" # root-language; this should
# catch all translations

translationstring='$local' # to identify the localization string

separator=\"_\" # the character _before_
# the root-language country code
# (see $label and $label2 below)

label=\"${separator}${translate_from}\"
label2=\"${separator}${translate_to}\"
#
------------------
####### no more editables below

set -f # no shell globbing
t="$IFS"
IFS="
" # here is just a newline, no whitespace
for filename in $(find . -name '*php' ); do
destination="${filename}${label2}"
# create/empty file
: > "$destination" || exit 1
linenumber=0
found=0
part=""
echo "
###### $filename"
for line in $(cat "$filename"); do
(( linenumber++ ))
echo "$line">>"$destination"
#print comments
echo "$line" | grep -E "^ *|^//"

#check for multiple line statements
if [[ $(echo -E "$line" | grep "$label") ]]; then
found=1
fi

if [ $found = 1 ]; then
# find the end of the sentence
if [[ $(echo -E "$line" | grep -E ';$') ]]; then
part="${part}${line}"
insertafterline="$linenumber"
sentence="$part"
# start translation
left="$(echo -E "$sentence" | cut -d= -f1)"
right="$(echo -E "$sentence" | cut -d= -f2-99)"
echo "__________________"
echo -E "$right"
echo "------ ${translate_from} -> ${translate_to} ----------"
read answer
echo -E "${left/$label/$label2} = ${answer}">>"$destination"

# reset values
part=""
found=0
# line continues
else
part="${part}${line}"
fi
fi
done #file
done # all files
exit
Bernard
avatar
from nearby-an-airport
Associate, 6927 posts

inspired from NickR on Oct. 30 2006


NickR: Yes, you will be able to change every string if you wish. Why not a en-NICKR locale? The implementation process will take time anyway, because of the so many scripts and strings to reshuffle.
Bernard
avatar
from nearby-an-airport
Associate, 6927 posts

inspired from vincent on Oct. 30 2006


Vincent: Thank you for your positive feed-back. After a couple of hours practicing poEdit, I must admit that this is really a good choice for interactive translation.
Vincent
avatar
from on-a-few-hops-from-you
20 posts

on Nov. 1 2006


This is all a waste of time .. since you have the localisation done

For people who don't want/cannot upgrade, i leave you with my sed(1) tinkering.

It gives you all the files with the language code after the filename, jou have to edit in the file itself to make the translation (and replace the .php file with the php_nl file

(needless to say this is exposure on 'my night with sed' )

i translate from en -> nl, hence _en and _nl

for i in $(find . -name '*php'); do cat ${i} | sed -r '/_en.*;$/p ; s/_en(.*);$/_nl\1;/ ; /_en/{ :getline ; $!N ; /;$/!{bgetline} ; p ; s/_en(.*);/_nl\1;/ }' >${i}_nl ; done

Let's break that down:

for i in $(find . -name '*php'); \ #find all .php files

do cat ${i} | \ #cat file, pipe into

sed -r ' \ #sed using full regex

/_en.*;$/p \ #find line with _en, ending in';', print

s/_en(.*);$/_nl\1;/ \ #find line again, change _en for _nl

/_en/{ :getline \ #find line with _en still in it

$!N #add an extra line from file

/;$/!{bgetline} \ #until ';' is found, or repeat from getline

p \ #print the _en version

s/_en(.*);/_nl\1;/ \ #change _en for _nl

}' \ #close sed line


>${i}_nl \ #put into file xxx.php_nl


done # repeat till finished

but real localisation with poedit is preffered

PS Bernard, now i come to think of it, this might be a very good starting point for you to dig out the locale strings... Tell me if i can help you with that!
Bernard
avatar
from nearby-an-airport
Associate, 6927 posts

inspired from vincent on Nov. 1 2006


Vincent: Thank you for your help on i18n and l10n... Actually the issue is not in extracting strings from YACS, but in changing the code to adapt to localization.

Before localization we had:
$local['label_en'] = 'a message';
$local['label_fr'] = 'un message';
$label i18n::user('label');



And after localization we have:
$label i18n:s('a message');



Therefore the need to review and change all scripts one by one...
Vincent
avatar
from on-a-few-hops-from-you
20 posts

inspired from Bernard on Nov. 16 2006


Bernard: kool - had some days off and then extra-busy days you know... Do you still need to go trough the files? In that case i could offer some help maybe? I see more lines like (in about.php, my favorite study object) :

if(Surfer::is_associate()) {
        $local['title_en'] = 'Help';
        $local['title_fr'] = 'Aide';
        $local['help_en'] = 'To change information displayed, go to the '.Skin::build_link('skins/configure.php', 'configurati
on panel for skins', 'shortcut');
        $local['help_fr'] = 'Pour changer l\'information affichée, allez sur le '.Skin::build_link('skins/configure.php
', 'panneau de configuration des styles', 'shortcut');
        $context['extra'] .= Skin::build_box(i18n::user('title'), '<p>'.i18n::user('help').'</p>', 'navigation', 'help');
}


 If i get you right there should be


if(Surfer::is_associate()) {
       
        $context['extra'] .= Skin::build_box(i18n::s('Help'), '<p>'.i18n::user('help').'</p>', 'navigation', '
To change information displayed, go to the '.Skin::build_link('skins/configure.php', 'configurati
on panel for skins', 'shortcut')
');
}

with the $local _en en _fr lines removed, right? i feel more tinkering comin' up ... v
Bernard
avatar
from nearby-an-airport
Associate, 6927 posts

inspired from vincent on Nov. 16 2006


Vincent: about.php, as all modules at the root level of YACS, have been processed. Would you be ready to internationalize a couple of modules after the release of the 6.10?
Vincent
avatar
from on-a-few-hops-from-you
20 posts

on Nov. 20 2006


Yeah i think i can do that. Please use the mail address from my profile. Hope to hear from you
Bernard
avatar
from nearby-an-airport
Associate, 6927 posts

inspired from vincent on Nov. 20 2006


Vincent: thanks for your help. I will contact you soon.

 
Share
Information channels
Recent files