Forum: Typo localization in general, Romanian localization file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Alex D. (Guest)
on 2007-05-05 19:43
(Received via mailing list)
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? :)

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

  3. 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"></script>

  4. Added translations in the file like this:
    l.store 'js_hours', 'ore'

  5. 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
Frederic de Villamil (Guest)
on 2007-05-06 14:25
(Received via mailing list)
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
This topic is locked and can not be replied to.