Browser specific GWT Datepicker Loaclization - gwt

GWT Datepicker is showing in "en" locale even if I change my locale to some other language. I dont want to specify it in some *.gwt.xml file, what I want is that it should take it from browser locale. Any workaround for this??????

Dynamic I18N as they call it is only about providing translated constants. For everything else (number formatting, date formatting, plural rules, etc.) you have to compile the supported locales within your app (<extend-property name="locale" values="…" />).
As an alternative, you can possibly override (using <replace-with> rules) the various implementations (in your case with DatePicker, the DateTimeFormatInfoImpl) with your own that would get their information from a Dictionary (or equivalent) rather than from compiled-in data. These APIs are subject to change between versions of GWT though (and I can already tell you that they will change in GWT 2.6).
In the end, it's probably easier to recompile your GWT app when you add support for a new locale, than go down the above-mentioned road.

GWT does not use the browser locale by default. You have to tell it to do so.
<set-configuration-property name="locale.useragent"
value="Y" />
<set-configuration-property name="locale.searchorder"
value="queryparam,cookie,useragent,meta" />
Be aware of that this does not work with all browsers. I suppose that's why it's not activated by default. So far IE is the only exception I know of.

If you want to use the browser locale (which is generally going to be pretty limited, not available in all cases, etc), then you want the combination of Thomas's answer (specifically specifying all the locales your app should support in extend-property tags) and setting the locale.useragent property (you don't need to set locale.searchorder unless you want to change the order or disable some provider).
Specifically, in your apps gwt.xml file, add the following:
<inherits name="com.google.gwt.i18n.I18N"/>
<extend-property name="locale" values="en"/>
<extend-property name="locale" values="fr"/>
... etc ...
<set-configuration-property name="locale.useragent" value="Y"/>
You don't need any replace-with rules. See GWT i18n docs

Related

Sitecore: Translating the URLs, what are the solutions?

I am totally new with Sitecore and one of my client told me she will create her website with Sitecore. She told me that she won't be able to translate url:
From: site.com/shoes/sneakers/
To: site.com/fr/chaussures/baskets/
She said she'll only be able to do: site.com/fr/shoes/sneakers/
Anyone is aware of a solution to that problem with Sitecore so we make sure we have translated URLs in French for a maximum SEO optimization?
All the best,
Alex
Item names can only be a single language, but you can use the Display Name instead as the URL.
To do so update the useDisplayName property of the linkprovider to true:
<linkManager defaultProvider="sitecore">
<providers>
<add name="sitecore"
...
useDisplayName="true" />
</providers>
</linkManager>
The display name can be translated to multiple languages allowing you to have different URLs per language.
Also be careful with language embedding. You may want to set this to always so en is also included otherwise it will throw Sitecore when visiting a french page and the visiting an en URL which does not have the language embedded. Sitecore will try to resolve the item in fr due to the existing lang=fr cookie.
https://stackoverflow.com/a/26929447/661447

GWT: External obfuscated CSS

GWT automatically obfuscates CSS name during compilation. I'm looking for way to externalize this CSS that was obfuscated by GWT after compilation, rather then inline it inside HTML.
Any suggestion? I still want to use the built-in compilation to obfuscate CSS, but I want to redirect the output to an external .css file. Is this possible? Does it needs a custom compiler linker? Any example on how to do this?
You can disable inlining of resources (all ClientBundle resources though) by adding the following to your gwt.xml:
<set-property name="ClientBundle.enableInlining" value="false" />

how can i make I18N dynamic in gwt?

i'm using gwtp and i want to make my gwt application's I18N dynamic, i did something likeshowcase example
is doing even though it is good but it is not the best way as it is reloading every time when locale is changing.
so i just want to change it to dynamic so that it allows me to change my locale at runtime,
thanks,
GWT compiles a different version of the code for each language in order to avoid users having to download all languages when they most likely only need their own.
If you do really want to make users download all languages because you want to change the language at runtime for whatever reason, you will have to do it in a completely different way.
There are many solutions for this (google Javascript Internationalization), none of which would involve the GWT way of doing things, as this is not very good practice and is discouraged by GWT.
By the way, if you mean you just want to change the locale at run time for testing, I hope you know you can just add the URL parameter:
http://your-url?locale=de
(for German locale)

Content not being displayed in the correct language

I am trying to make this decision on what content (Messages) to be displayed based on the useragent. Everything works correctly when I user query param, or a meta tag. it also works correctly in Firefox. In firefox I change the language from english to french, reload the page and everything comes up correctly. This is baed on the useragent. If I load the page in chrome/IE I get the default (English) only. If I set my system language to French (my other language) everything seems to work as well. Any ideas why setting the language in chrome and IE have no affect no the content? I verified the headers and the requests are being made for French content? What am I missing?
My gwt.xml file is based on the one I found here http://code.google.com/p/google-web-toolkit/source/browse/releases/2.3/user/src/com/google/gwt/i18n/I18N.gwt.xml
It was my understanding that all I needed to add was the following to my gwt.xml
set-configuration-property name="locale.useragent" value="Y"
Also I found the following Why does GWT ignore browser locale? which seems to indicate it won't work in IE but what about chrome?
See http://code.google.com/p/google-web-toolkit/issues/detail?id=4228
TL;DR: there's no reliable way of getting the info you're looking at in JavaScript, the navigator object gives you the locale of the browser (i.e. the one used for the browser's own menus et al.), not the user's language preferences (except in Firefox).
Your best bet is to use a dynamic host page and generate the appropriate <meta> on the server depending on the request headers (i.e. content negotiation).

is it possible to dynamically include scripts via .gwt.xml?

how can i take advantage of GWT's deferred binding mechanism for script resources (e.g. CSS, JavaScript)?
the <define-property ... /> and <set-property ... /> ( when used in conjunction with <when-property-is ... /> ) does not provide this functionality since they're used for Java types binding.
thanks in advance!
Since the is used for Java types, you can use that paradigm and wrap your css and js in java/gwt classes. The js will use the native js interface to wrap up the methods and the css can be included in a CssResource/ClientBundle class. Then just use the gwt.xml file to use whichever one you need for the conditions you have.