rails 3.1, How to manage URLs for a multilingual website? - ruby-on-rails-3

I would like to know please, what is the recommended way to develop a website with two languages:
Arabic ( Right To Left )
English ( Left to Right )
URLs will have a two characters to specify the language, like:
www.domainname.com/ar/homepage or www.domainname.com/en/homepage
so, the router shall be able to add ar, en for each url ...
I know that I my controller should work for both languages, but, how to pick the right css for the chosen language ? is there a blog or tutorial for this case ?
Also, as for the data base, shall I add a field of content for each language ? what's the recommended approach for that ? for reading and writing ?
Any guidance will be more than appreciated!

I would use I18n and then scope the urls, but I suggest that you read this article on I18n, to get a firmer grasp of the concept.

Related

Switch to the another language on the same page?

I am trying to add a language changer for Middleman and it's not generating the correct link. My default and root is English.
url_for("/#{current_page.path}", locale: :ja)
I would expect the equivalent for the current page in JA which is the same URL with JA prepended. Does anyone know how to fix this?
I'm a middleman beginner, but after doing a bunch of Googling it seems like this is a fairly common issue. I've tried to look through the middleman sources to see if I could find a solution, but I've been unable. I'm kinda disappointed about this, because it looks like middleman has first-class support for localizations. Being unable to easily link from one to another seems like a surprising omission.
What I've done is make a little helper that can swap localizations in paths, if needed.
def change_locale_in_path(path, locale)
locale_prefix = I18n.locale
path.gsub(/^#{locale_prefix}/, locale.to_s)
end
This isn't a great solution, though. It will need to be adjusted if you change the i18n :path, and won't work unless you mount_at_root: false. But, it worked well enough for me to move on. I really would love to see a better solution.
I found a few GitHub issues that seem to reference this problem. Here's one.
I am using the following helper to generate a URL for the current page in a different language. It was originally based on this gist, and then tweaked it a bit so that it works regardless of whether mount_at_root is used.
def current_url_for_locale(loc)
url_regex = /\A\/(?:(#{I18n.available_locales.join('|')})\/)?/
locale_root = url_for('/', locale: loc)
current_page.url.gsub(url_regex, '').blank? ?
locale_root :
current_page.url.gsub(url_regex, locale_root)
end

tx_news and multi-language

I'm using Typo3 6.2 and EXT tx_news in a multilingual installation (L=0 German, L=1 English, L=2 Italian, with more to come). Everything works fine if I make a newsrecord in standard-language and translate it via localization to the other languages.
Here the problem:
Some news should only be in one specific language, not necessarily the standard language.
But if I create a newsrecord telling it should be Italian for example, no pictures are shown in the FE, neither in list- nor in detail-view. The pics are in the record, marked as "Show at list-view" (maybe wrong translated, I'm using the BE in German), but in the outputted code, the news-image-wrap is empty:
<div class="news-img-wrap"> </div> == ยง0
Would be very pleased to get help here!
I don't think it is a problem of wrap.
It sounds like a problem of translation handling. dio you use translation or only multilanguage?
You might need a record in default-language with the option not to be shown but with the images for all languages.

Gracenote API: Search and fetch contents in specific language

I'm wondering if there is a way to get data in specific language when using gracenote series_search or series_fetch methods.
It turns out that using ger field is useless... I still get data in english ...
If someone could help resolving this, that would be great! =)
Gracenote uses 3-letter ISO 639-2 codes to specify languages. The format is described at http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes - Gracenote supports most major languages.
Thanks to your suggestion, we've added this documentation to our page at: https://developer.gracenote.com/eyeq

Using elm for front end development + serving dynamic elm pages though haskell

I started with elm yesterday and I really enjoy using it. Without any experience in front end development I could build a nice looking webpage in only 30 lines of code, which is amazing.
Now I really want to use it in a real life example, I want to build a small blog.
But I need a way to communicate with elm. For example I need to query my database and I get a list of blog entries [Blog] and now I need to pass them to elm.
I am not sure how I would do it. I was looking though the popular haskell frameworks like yesod snap and happstack and the first thing that I found was http://hackage.haskell.org/package/snap-elm-0.1.1.2/docs/Snap-Elm.html
But it seems it is intended for serving static elm files, but I need to pass arguments to it.
Any framework that you would recommend me that already has elm support for serving dynamic elm pages?
And if not, how would you do it?
My idea was just to use elm as a skeleton and then I generate a normal html file with yesod snap or happstack and integrate this file into elm. Would this be possible?
Something that would look like this
container 1000 1000 middle <| displayHtml "/pages/my_generated_html_page.html"
Edit:
My first hacky solution was this
tPage = plainText "<script src=\"http://code.jquery.com/jquery-1.10.1.min.js\"></script>\n
<script> \n
$(function(){\n
$(\"#includedContent\).load(\"/home/maik/b.html\"); \n
});\n
</script> \n
<div id=\"includedContent\"></div>\n"
Unfortunately I am not allowed to use script tags in elm.
I recommend studying elm-lang.org's source code. The majority of it is pure Elm but there are pages that are generated on the server side with Haskell.

How can I use the Disqus comments in my three-language site in all three languages different?

How can I use the Disqus comments in my three-language site in all three languages different? I saved one language and I cannot use else.
Referencing this doc, there are a couple of ways to have a multi-lingual site:
Create as many Disqus shortnames as you need languages, and reference those shortnames in each language portion of your site where you load Disqus
Use the following javascript override to load different languages per-page:
var disqus_config = function () {
this.language = "ru";
};
Use option #1 if you want to moderate or manage each language separately. Option #2 is good if those moderating can do so in either language.