I have a PO file (N. Po and FPO) that I use to use my Rail application for localization in French Want to I recently presented the question that can I get any help. I have mentioned that I had read some information about Fast-Gatetext and any other gem. I have decided to see the fast gettext gem since it allows the use of PO files without using a database.
I added the latest version of fast_gettext and gettext_i18n_rails in my Gemfile. I have installed the latter gem to get rid of an undefined method "_" error message, although at this point I do not have any plans to use the database feature.
I added the following code to config / application.rb. Here's permission to set and save the location using my setup cookie in application_controller.rb. I argue where the user clicks a flag and the value of Can be set said:! Locale When a person clicks on the flag, then the value is determined: locally correct. I have my routes formatted as domain.com/.locale/link. I will not include the locale in the root until I add the argument to override it. There are two statements in my thoughts with whom I am testing: Click on the French flag to change the value of: Link changes the link from "fr" properly but the code for both strings resides in English. The PO file is a French translation for both of these terms. If I can not find PO files then I know this. Should have seen error message in. I tried to use configuration code in config / initializers / fast_gettext.rb but did not get any results, so I did it in config / application.rb Decided to put it, to see if I can work it. I also removed ': ignore_fuzzy = & gt; true, report_warning = & gt; wrong' to see if things can change Although I get the same result. I fast_gett Ext as it was back in 2011 by Esfooch, recommending it to use Gettext. I can try and contact him on Twitter because it seems that the only place I can get is where he is active these days. Any help would be appreciated. Why are you using PO files instead of normal files? Or if you prefer to save translations to the database and add a model translation. There is also a gem to help you convert your existing translations. # Fastgatex Configuration Fastgatex Add_text_domain 'my_app', add: path = & gt; 'Config / locales' ,: Type = & gt; : Po ,: ignore_fuzzy = & gt; True, report_warning = & gt; False FastGettext.default_text_domain = 'my_app' # default textdomain FastGettext.default_available_locales = ["n", "fr"] # set available places # (note set: first one is used as a back coming if you have a missing place Setting Attempt) FastGettext.default_locale = 'N'
FastGettext included :: translation before_filter: set_users_locale def set_users_locale I18n.locale = FastGettext.set_locale (parameter [: location] || cookies [: location] || request.env ['HTTP_ACCEPT_LANGUAGE'] || 'en') Cookies [: Location] = I18n.locale if cookies [: location] = I18n.locale.to_s end
& lt;% = link_to_unless_current IMAGE_TAG ("flag_us_30px.jpg", alt = & gt; "English language to set up"), location: "n"%> & Lt;% = link_to_unless_current image_tag ("flag_fr_30px.jpg" ,: alt = & gt; "Set Language to French"), Location: "fr"%>
& lt;% = _ ("language")%> & Lt;% = _ ("Note: If you do not understand the text on the icon, use the text link at the bottom of the page.)%
No comments:
Post a Comment