J2EE + Struts2: Internationalization + Text Alignment - struts2

I want to know following about struts2:
Does internationalization works for Arabic & English? Any special considerations?
How can I change the alignment of text when locale is changed? For English it will be left aligned and for Arabic it will be right aligned?
How can I intercept (during) the change of locale so, that I can reload the information on the page which is being fetched from the database?
We also need to adjust some styles (css) since text with non-english alphabet/characters tend to take up space differently. Can we also “internationalize” css files?
Any working example with this scenario.
Any help will be great.
BR
SC

1) Yes. Make sure all characters in the message bundle are unicode escaped and not the actual characters.
2) You can use the css or html: see http://www.i18nguy.com/markup/right-to-left.html. In out application, the Arabic is actually in the file in the proper direction so we did not have to change any styles.
3) In Struts 2 you can set the session WW_TRANS_I18N_LOCALE. See http://struts.apache.org/2.0.14/docs/localization.html and http://struts.apache.org/2.0.14/docs/i18n-interceptor.html
We had some trouble getting the language to store so we explicitly set that variable in the session
Locale locale = (Locale) getSession().get("WW_TRANS_I18N_LOCALE");
if (!(locale instanceof Locale) || !locale.getLanguage().equals(new Locale(languageCode, "", "").getLanguage())) {
getSession().put("WW_TRANS_I18N_LOCALE", LocaleUtility.langToLocale(languageCode));
}
4) Yes you can create mycss-ar.css, mycss-en.css and load the proper file based on the locale.
5) Sorry I don't have any code to supply.

Related

How to link to internal link with ampersand?

I am trying to make an internal link to a heading called "word & word".
Since I am using Jekyll, the content is in Markdown files and the heading I want to link to looks like this:
### word & word
I know that I can not use & in URLs.
Therefore this would not be an option:
#word-&-word
I also tried:
#word-%26-word
and
#word-&-word
#word-%26amp;-word
#word-%20amp%3B-word
However, both versions are not working.
What would be the appropriat way to fix this?
Kramdown is striping non alphanumeric from header id's and replacing spaces by -.
You can just check this behavior with :
- mandatory
{:toc}
### word & word
Resulting link in generated table of content is #word--word
See kramdown documentation

iOS localizable string with default values

I want to understand how localizable base string works in iOS. For example, in Android if I have got a default localizable file strings (base localization on iOS) like:
"title_app" = "Title"
"Copy" = "Copy";
"Edit = "Edit;"
And then I have got a Spanish localizable file like:
"Copy" = "Copiar";
"Edit" = "Editar";
Why on iOS if I set Spanish language on my device the key "title_app" doesn't appear? Because Android if doesn't find a key, it takes the key from the default language.
Sometines there are words that they don't need a translation. Or sometimes I have 10 languages and maybe one language needs a translation from a non translatable word. For example "title_app" = "My app". It will be the same in English, French, Italian, Spanish... but in chinese no. It is not efficient write the key on 10 files, repeating... imagine 10, 20 o 50 words.
Always Apple/iOS is far behind in matters of translation/localization compared to Android... :S
Talking about translation; sorry my bad english.
The NSLocalizedString macro takes two parameters, a key and a comment. The key will be looked up in Localizable.strings file, which is a simple key-value pair collection.
As #TheEye pointed out in the comments via the blog post link, you can exercise more control, and explicitly include a default value by using the NSLocalizedStringWithDefaultValue macro instead.
What you have to realize is that you have a choice: you can either use the simpler macro and treat your key as the default value (and iOS will fall back to that) or use the more specialized macro that is more verbose but gives you more control instead.
Note, this has already been discussed here: Fallback language iOS (with incomplete Localizable.strings file)

using 18n and I18n:Alchemy in rails in order to translate a text value according to the locale

In my application, there is a field credit_debit that has two string values: 'credit' and 'debit'.
These two terms should be shown in a localized form to the user, so that when the app is using an italian locale they should be translated into 'avere' and 'dare'.
I could write my own setter/getter method for the credit_debit field and handle this issue inside it, but maybe I could leverage the I18n architecture to do so in a way that is consistent with the rest of the localization. If it's possible, how can I implement this?
Can't see the problem if you're already using i18n localization.
Just use the field as a key for i18n (with a prefix if you like)
t("prefix_#{credit_debit}")
and just define the strings for both your locales.
So in your en locale:
prefix_credit: credit
prefix_debit: debit
And in your it locale:
prefix_credit: avere
prefix_debit: dare

Symfony/Doctrine: Fallback to default culture for i18n content

I am building a multilingual website with Symfon 1.4/Doctrine, having English language defined as primary.
Content translation in other languages are added gradually, and there will very often be situations when translation of the content requested will be unavailable in requested language. I want to display the requested content in English in those cases.
Is this achievable at global level, e.g. for all the i18n content?
As pointed by Grad van Horck, this works fine by default for interface translation.
What I need is the same functionality for content stored in DB (models having "actAs i18n" behavior).
The default way allows perfectly for this. Just make sure all your texts are in English by default, and translate them where needed. So just do <?php echo __('Hello'); ?>, and then translate it if you want. If a translation can't be found, it just falls back at it's 'original'.
To do the same in your database, you'd probably be best of copying the i18n behaviour (Template/Listener) and add your own bit of logic to fall back on English.
It's possible to set the default culture on sfDoctrineRecord (see http://trac.symfony-project.org/ticket/5458)
sfDoctrineRecord::setDefaultCulture('nl'); // default = 'en'
This changes the i18n fallback when the translation isn't available in the database.

Umbraco Content Name

In Umbraco CMS, I would like to prevent the contents to have names having invalid URL character such %, > and etc.
How should I do that?
Regards,
Nami
Have a look at your /config/umbracoSettings.config file, it already has a set of replace characters, among which the % character. You can add more if you want to.
If, for any reason you would want to completely prevent those characters in the nodename, you would have to write an afterSave eventhandler so you can do the replace in your own custom code.

Resources