Open onaseef opened 12 years ago
I can't really quantify without looking through every file, but it's all done the same way.
For any .slim
or .erb
file, you take an existing string Example Text
and replace it with:
t('my.namespace.example')
Then, in en.yml
, you set up the text in whatever namespace you used:
en:
my:
namespace:
example: "Example Text"
I personally think internationalization is premature optimization. I'd work on the other issues before this one.
What are the other issues you'd prioritize?
The reason we're doing the internationalization is we want to target emerging markets and we need a spanish language version of the site, sooner rather than later, to do that
If you're engaging new markets, I suggest having payments and premium accounts done beforehand.
For emerging markets, they don't handle electronic payments so well, so there's no value add there. But having a spanish language version fo the site means they can immediately adopt it.
In terms of getting more users on board, we'd need to have the internationalization in place so we can target spanish language market right away. The online payments would only really apply to developed markets.
Are you anticipating that internationalization is going to be a big deal?
I can go through the code and look for hard coded items and follow the practice you mentioned, assuming the infrastructure is already in place. Like, right now, does the system know to pick the right yml file? Does it know to automatically replace phrases? Is the only thing that's missing the pulling out of the hard coded phrases and replacing them with the variables?
It's not a big deal, it's just time consuming to go through all the strings. Setting up server side will take an hour at most.
I can go through all the strings if all of the infrastructure is in place on the back end to handle both the desktop builder and the mobile site. If you'd set up a skeleton, I can take over from there.
Both should use the local language to present the version of the site. There'd also be a link at the bottom that lets the user pick the language they want.
It will infer language from request metadata. The language picker will take a bit longer, up to an hour, and I'll make it so the language saves to the user if he's logged in. What do you want the ui to look like?
On the home page, the language list would be similar to facebook, where you'd see the most common languages listed in their native language to be picked.
On the inside, the language picker can be a drop down list in the account settings page, if the person has a preferred language, they'd pick it there.
Please tell me the formats I need to use to internationalize these file types:
widget_icons.yml (or do i need to create widget_icons_en.yml)? If so, we'll need to update the code and create new directories for each language with the appropriate files.
The two yml files you'll be editing are en.yml
and es.yml
(a new file for spanish).
widget_icons.yml
won't work without a bit of additional effort. If you need to internationalize any files that do not end with .slim
or .erb
, then record them on a list. I'll update the code to enable internationalization with the listed files in one batch.
We will need to internationalize any file that is used to show customer facing text. I've listed the ones I've managed to find so far. All files should be set to be internationalized according to standard best practices for internationalization.
widget_maps.yml widget_icons.yml edit-widget.js category.js site-manager.js
device.en.yml (i assume this is actually already internationalized, so you'd do the same thing with widget_maps)
In index.html.slim line 110, I can't figure out how to internationalize: p.error "You are at your site count limit (max is {{ errors.maxSiteCount }})"
while passing errorsMaxSitecount to the string
widget_maps.yml widget_icons.yml edit-widget.js category.js site-manager.js
I'm working on getting these files to use I18n. It's more involved than I thought.
I had to do a lot of research to find out how to work this out. Basically I'm loading those yml
files in a rails initializer, but for some reason i18n doesn't get loaded until after the initializers. Not even the rails experts in the irc channel knew this.
Anyways, I now know how to do this, and I'll continue on it (as well as the other issues) tomorrow.
I converted the file widget_icons.yml
to use i18n. It now only contains a list of icon file names, and the "pretty names" (known as pname
in the code) now live in config/locales/widgets/en.icons.yml
. If you duplicate this file and rename it as es.icons.yml
, you should be able to make a spanish version.
The changes are:
?locale=es
will enable the es
locale.
en
locale.-
Take a look at the current setup on branch home-redesign
and tell me what you think. If it works I'll continue the translations for the other files as well.
Thank you for the update Gilbert. I'll test it as soon as I can. Question: When you say the locales are derived from the URL, is that in addition to the system checking the system locale and automatically selecting the language? The URL variable should only serve as an overwrite of the system locale. Is that how it works?
On Mar 23, 2012, at 12:57 PM, Gilbert wrote:
I converted the file
widget_icons.yml
to use i18n. It now only contains a list of icon file names, and the "pretty names" (known aspname
in the code) now live inconfig/locales/widgets/en.icons.yml
. If you duplicate this file and rename it ases.icons.yml
, you should be able to make a spanish version.The changes are:
- The locales are derived from the url. Adding
?locale=es
will enable thees
locale.
- By default the app uses the
en
locale.- Dots are no longer allowed in widget icon filenames
- I've already changed them all to dashes
-
Take a look at the current setup on branch
home-redesign
and tell me what you think. If it works I'll continue the translations for the other files as well.
Reply to this email directly or view it on GitHub: https://github.com/onaseef/yomobi/issues/208#issuecomment-4664558
It isn't possible to read the system locale. However, sometimes the request states which languages it can accept. Right now it attempts to detect a language in the following order, short-circuiting when it finds one:
locale=xx
parameterHTTP_ACCEPT_LANGUAGE
request headeren
as a fallbackOops, yes it's supposed to set it for their session. I just fixed it.
I tested es.icons.yml and it works. What's the status of the other YML and .js files? Will you need to create a new file for widget_map.yml and other files for the .js files? Ideally it would be great if we could put as much of the translation into a single
The js files have been set up. The only problem left is the widget_maps.yml.
The only issue with this is that the names get saved to the database when the site gets created. I can make it so it saves names based on the current locale, but they won't change when the locale is switched to another language.
The user can rename files as they choose. So long as we initially set the names properly on setup, we can leave it to the user to change the names afterwards.
In site-manage.js on lines 309 & 310, are the "Create" and "Cancel" buttons i18n compliant?
Let me know if I missed anything else.
Any i18n that will be used in a .js
file needs to go under the javascript:
key (line 48 in en.yml).
I'll get the sidebar names done in a bit.
These files need to be made i18n complaint
Updated.
jwysiwyg has a i18n plugin, but I had to customize the way it includes translations. en.yml does not have the translations (it just uses the plugin's defaults), and es.yml has the translations attached at the bottom of the file, under the jwysiwyg:
key. Other language translations for jwysiwyg are available here.
The following files need to be i18n. I started working on the erb files but there seems to be a problem. All of the necessary strings are in en.yml and es.yml already. I just can't seem to replace the text correctly in the erb and I don't know how to debug it. I don't even want to try the .js file because I don't want to break anything.
leave_message.js call_back.js booking.js informed.js booking_email.html.erb leave_msg.html.erb call_back.html.erb tell_friend.html.erb
Updated.
Please i18n the file: signup_controller.rb - line 13. I don't know the correct syntax here. The replacement string is already in the es.yml & en.yml files - account.already_setup'
I don't know if there are other lines that need to be replaced, but please check
Updated.
Change Icon dialog "Save" "Cancel" buttons need to be i18n complaint
Updated.
In views/builder/_templates.slim
Line 58: b Added <% print( util.pluralize(typeName) ); %>:
Not sure how to work in the variable.
The phrase to use is: t'dialog.add_page.added'
Updated.
We need to fully internationalize Yomobi.com, which means pulling out all hard-coded text from everywhere and using language files based on the locale.
How much work is this?