Localization in general, Romanian localization file


#1

Hi,

A. I’m not sure who to tell about this, but I’ve created a
localization file in Romanian, and I’d like to make it available for
inclusion in the next release. Will an administrator tell me where to
send my lang/ro_RO.rb please? :slight_smile:

Incidentally, I’ve also fixed a few other files whose strings weren’t
localized. At the time I’m writing this mail, they are:
vendor/plugins/xml_sidebar/views/content.rhtml
vendor/plugins/category_sidebar/views/content.rhtml
app/helpers/articles_helper.rb
views/shared/_search.rhtml

I’ll keep on patching them. If anyone’s interested, I can make them
available too.

B. Another thing which is, in my opinion, not very nice is that there
are some Javascript strings which can’t easily be localized using the
_() notation. Among others, that’s why you’ll always see “x hours
ago” in English, regardless of your configured language.

To fix this, I’ve done the following 5 steps:

  1. Patched localization.rb by adding:
    def self.all_keys
    @@l10s[lang].keys
    end

  2. Added a method in articles_controller.rb:
    def localized_js

    We only retrieve translations which have to do with the

Javascript strings; we don’t want to overload the browser.
js_content = Localization.all_keys.collect { |key| if key =~ /
^js_(.+)/ ; $1 end }.compact

  render :content_type => 'text/javascript', :text => 'var

LocalizedStrings = {’ +
js_content.collect { |key| lkey=“js_#{key}”; “”#{key}" :
“#{_(lkey)}”" }.join(’, ') +
‘}
String.prototype.localize = function() {
var s;
if(LocalizedStrings && (s=LocalizedStrings[this]) )
return s;
return this;
}’
end

  1. Added a line in the default.rhtml of the active theme (maybe
    there’s a better place for this, but I couldn’t find it yet):
<script src="/articles/localized_js" 

type=“text/javascript”>

  1. Added translations in the file like this:
    l.store ‘js_hours’, ‘ore’

  2. In all Javascript code, I replaced strings like this:
    Before: “hours”
    After: “js_hours”.localize()

C. In Romanian (and other languages), words used to express time
difference from now (like ‘ago’ and ‘from now’) prepend the numeral,
contrary to the English rules. That is why I also had to change some
logic in the function get_local_time_for_date() (file typo.js) and
translate ‘ago’ and ‘from now’ as the empty string.

That’s it for now. Sorry for sending all this in an email. If an
admin feels I should be submitting these as patches, please tell me
how. I’ve only been using Typo for a few hours. Thanks!

Alex D.
Indigenious Development
www.indigenious.ro


#2

Hi,

For the localization file in .ro, open a ticket on the trac and add
it as an attachment, I’ll add it to the trunk after.
For the js change, create a patch, open a ticket on the trac and add
it as an attachment, and maybe I’ll add it after a few testing.

Cheers,
Frédéric

Le 5 mai 07 à 17:41, Alex D. a écrit :

vendor/plugins/category_sidebar/views/content.rhtml

   # We only retrieve translations which have to do with the  
              var s;

change some logic in the function get_local_time_for_date() (file


Typo-list mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/typo-list


Frédéric de Villamil
removed_email_address@domain.invalid tel: +33 (0)6 62 19 1337
http://fredericdevillamil.com Typo : http://typosphere.org