# Localization in general, Romanian localization file

**URL:** <https://www.ruby-forum.com/t/localization-in-general-romanian-localization-file/103415>\
**Category:** Typo\
**Created:** [May 5, 2007, 5:43pm UTC](https://www.ruby-forum.com/t/localization-in-general-romanian-localization-file/103415 "2007-05-05T17:43:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [May 5, 2007, 5:43pm UTC](https://www.ruby-forum.com/t/localization-in-general-romanian-localization-file/103415/1 "2007-05-05T17:43:01Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![alexd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/96bed5/32.png) [@alexd](https://www.ruby-forum.com/u/alexd)\
**Post date:** [May 6, 2007, 12:25pm UTC](https://www.ruby-forum.com/t/localization-in-general-romanian-localization-file/103415/2 "2007-05-06T12:25:27Z")

</div>

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](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](http://fredericdevillamil.com) Typo : [http://typosphere.org](http://typosphere.org)
