Internationalization in JSF, when to use message-bundle and resource-bundle?

<message-bundle> The <message-bundle> is to be used whenever you want to override JSF default warning/error messages which is been used by the JSF validation/conversion stuff. You can find keys of the default warning/error messages in chapter 2.5.2.4 of the JSF specification. For example, Messages_xx_XX.properties files in com.example.i18n package as below which overrides the default required=”true” … Read more

PHP function to make slug (URL string)

Instead of a lengthy replace, try this one: public static function slugify($text, string $divider=”-“) { // replace non letter or digits by divider $text = preg_replace(‘~[^\pL\d]+~u’, $divider, $text); // transliterate $text = iconv(‘utf-8’, ‘us-ascii//TRANSLIT’, $text); // remove unwanted characters $text = preg_replace(‘~[^-\w]+~’, ”, $text); // trim $text = trim($text, $divider); // remove duplicate divider $text … Read more

How to support Arabic text in Android?

Android 2.1 does not have Arabic font. Android 2.2 has Arabic font but does not show your word correctly. Android 3.x supports Arabic completely. For Android 2.1 you must set the typeface Farsi.GetFarsiFont(this) and then use Farsi.Convert(“سلام”) For Android 2.2 you do not need setting font but must use Farsi.Convert(“سلام”) And for Android 3.x forget … Read more

How to internationalize/localize a JSP/Servlet web application?

In case of a basic JSP/Servlet webapplication, the basic approach would be using JSTL fmt taglib in combination with resource bundles. Resource bundles contain key-value pairs where the key is a constant which is the same for all languages and the value differs per language. Resource bundles are usually properties files which are loaded by … Read more

How to force NSLocalizedString to use a specific language

NSLocalizedString() (and variants thereof) access the “AppleLanguages” key in NSUserDefaults to determine what the user’s settings for preferred languages are. This returns an array of language codes, with the first one being the one set by the user for their phone, and the subsequent ones used as fallbacks if a resource is not available in … Read more

JavaScript for detecting browser language preference [duplicate]

I think the main problem here is that the browser settings don’t actually affect the navigator.language property that is obtained via javascript. What they do affect is the HTTP ‘Accept-Language’ header, but it appears this value is not available through javascript at all. (Probably why @anddoutoi states he can’t find a reference for it that … Read more