Can someone explain how to use this feature. i'm trying to search for an example on the web but not getting it. Also, if at run time, the user wants to change language, how to do so??
According to docs, you can
either specify "locale" GET parameter in your URL, for example:
http://www.domain.com/application.html?locale=fr_CA
or add meta tag to your host HTML page, for example:
You may find complete internationalization example here - it uses locale get parameter approach.
As far as I understand, there's no way to change localization without GWT module re-loading (see here for details).
Both these approaches are static. But for the dynamic approach, this is very hard. Based on the current user's locale, change the ui rendering is NOT that easy...
If any
Related
TLDR: I want setup an AEM page that accepts firstname and lastname as parameter using an SEO friendly URL.
Going to www.host.com/mycontent.richard.williams.html will display information relevant to Richard Williams.
If I go to www.host.com/mycontent.john.smith.html, the page will display information relevant to John Smith.
SEO friendly example: www.host.com/mycontent.richard.williams.html
not SEO friendly example: www.host.com/mycontent.html?firstname=richard&lastname=williams
So I've been following this guide (not sure if this is the best example/guide to help me): http://www.aemcq5tutorials.com/tutorials/sling-servlet-in-aem/
And while it works well for my the example
#SlingServlet(resourceTypes="geometrixx/components/hompepage", selectors={"firstname","lastname"}, extensions="html",methods="GET", metatype=true)
I am trying to make it dynamic.
At the moment, I can only access the servlet if access via: http://localhost:4502/content/geometrixx/en.firstname.lastname.html
I want to make firstname and lastname dynamic parameters/selectors. Like if for example I want to pass the values "richard.williams", I can then use: http://localhost:4502/content/geometrixx/en.richard.williams.html
if I try to use http://localhost:4502/content/geometrixx/en.richard.williams.html right now, I get a blank page.
So basically I want to use selectors for passing parameter values to my page.
Any ideas how this can be done?
ps. At the moment, I only testing/experimenting in my local instance of AEM.
Selectors in sling don't provide the functionality of placing variables in the URL path. i.e. you cannot add {pathParam} like in Spring to sling servlet URL.
In general, selectors are not recommended to be used like an input to a function. They are to be used more like file extensions.
For eg. A request to /mycontent.html returns the same resource as /mycontent.mobile.html. The only difference being, the latter requests for a mobile friendly version.
Request params on the other hand serve the purpose of providing inputs to the servlet.
I cannot think of any direct way to attach a servlet to dynamic paths in sling. You can try using suffix, they are cacheable in the dispatcher, but I can't comment on the SEO friendliness of using suffix.
Consider this URI - /mycontent/user.json/john/smith
Register a servlet using the path /mycontent/user and you can use
String[] names = request.getRequestPathInfo().getSuffix().split(suffix, '/')
to retrieve the suffix contents.
Take a look at answers in this question. Sling ResourceProvider and integrating with jax-rs are other ways you can accomplish this.
Technically this would be feasible with the use of OptingServlet (see https://sling.apache.org/documentation/the-sling-engine/servlets.html#optingservlet-interface)
Your accepts method could easily recognise the expected resourceType and react appropriately.
As mentioned in the docs this approach is discouraged and the solution proposed by Subhash to use suffixes seems way more elegant.
You can create a components which reads selector from the request and add that compoent to en.html
I am trying to translate my WordPress website (built using Brooklyn theme) but I do not know which method to use to translate my strings. At first, the strings weren't showing up in the string translation search but then I learned that I had to add more code.
My first question is, do I have to go through every single page and custom CMS entry that I use to update content and wrap everything in code, or is there a way to do that automatically?
Secondly, I use Brooklyn theme but their support team is so slow so I wanted to ask if there was a standard way to find the theme's text-domain to include in the code (if I need it).
Thirdly, I know the options I have with which method to use to translate strings (manual registration or GetText) but I haven't found any explanation relating to where to put this code and how to implement it (even the official documentation gives you the code but doesn't explain what to do with it and I'm not a PHP expert!)
I'm using all the latest versions of WPML and the multilingual CMS.
http://www.expedition-polaris.com
Yes, you'll have to wrap all strings that you want translated with one of the localization functions ( https://codex.wordpress.org/L10n ) : __(), _e(), _n(), etc.
If you have already purchased the Brooklyn theme, then grep through the source for either _e( or __(, to find out the text-domain., or if you run the scan function via the String Translations admin page, the text-domain should be listed for the theme.
Based on what GWT at the client side knows about the time-zone? Is it somehow retrieved from user-agent (browser) which in turn has it from OS settings? I tried tinkering with my OS time-zone settings but did not any different.
Is there a way to set the default time-offset/time-zone to be different at the client side code? Reason for this is usage of Date api methods which apparently return results based on the defaul time-offset/zone settings.
You cannot change settings on a user's computer or in a user's browser. That would be a huge security hole.
To display date in the desired time zone, create and pass a TimeZone object to the DateTimeFormat.format() method.
Please have a look at my post Setting locales in gwt.xml do not work where I have explained it with sample code.
Specially look at gwt.xml and where you can define locale.
Hint:
create the DefaultDateTimeFormatInfo based on client (browser/navigator) language
create the DateTimeFormat based on DefaultDateTimeFormatInfo
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)
I'm developing a multi-lingual site.
I've put a Zend_Translate object in the Zend_Registry and I use it to translate all static texts to the selected locale.
My question is how do I change the locale when the user chooses another language?
If I get the translate object from the registry, call setLocale , and put it again in the registry , will it hold only for that user or for the whole application?
Thanks.
You will need to use a plugin for that.
In short: create your plugin and add the routeStartup() and routeShutdown() methods to it. In the former one, set the locale string in a request param and, if needed, also set the requesr URI to contain the locale string. Correct locale string detection is up to you - you can either use a cookie, URL parametre, browser's accepted language header or any combination of the three. In the latter one, create your Zend_Translate object based on the locale you have set earlier.
Here is how it looks like in my CMS.
Here is a tutorial regarding the use of the language parametre in the URL. You may also check how I do it in my CMS (see the _initRouter method).
I hope this info is helpful.
Use Poedit for this purpose ..go thru this link for more
techie.ayyappadas.com/how-do-use-poeditor