Zend default route not working - zend-framework

I'm trying to add multi language functionality to an existing application.
My URL's look like this:
Without language: www.example.com/controller/action/params
With language: www.example.com/de/controller/action/params
If :lang is not specified ('de' in the example above) it should take the default language (set in the ini) or just use Zend_Translate default keys.
Both of the URL's above need to work.
My Problem now is the following: I'm able to activate get the first URL with the :lang working, but then the default one doesn't work. Why?
Somehow, the chaining of the default route and the language rout doesn't work properly.
My code is the same (for the chaining/routing stuff) like here: http://devzone.zend.com/1765/chaining-language-with-default-route/
I'm not using modules (actively, of course teh default stuff is enabled), maybe my default route (same as in the code) is just wrong? Althought it works, if i disable the language rout and chaining.

Related

angular Routing without Hash

I want angular routing without hash in Url.
I want Url as http://localhost:56629/Victoria/Home
So Use this Location Provider is to set Html5 mode true.
But Now the Url Becomes http://localhost:56629/Victoria#%2F/Home. i guess it takes the ascii value of ('/')
But the Controversy is that this (Victoria) is Not static Name. this name is Binding with angular Binding.
By Setting Up the Routings On Server Side, this problem is solved

How to get request properties in routeStartup plugin method?

I'm developing a multilanguage application, and use routes with translated segments. For multilingual support I created special Multilingual plugin.
To use translated segments I need set translator for Zend_Controller_Router_Route before routes init. So only possible place for this in my plugin is routeStartup method, but there is one problem here - for determine right locale I need to use properties of request (Zend_Controller_Request_Abstract), like module, controller and action names, but they are not defined yet here in routeStartup method. They are already defined, for example, in routeShutdown - but I can't set translator for route there, because it have to be done before routes init.
So what can I do:
can I get request properties somehow in routeStartup
or can I re-setup translator later in routeShutdown
P.S: there is a question with exactly the same problem Zend_Controller_Router_Route: Could not find a translator, but proposed answers is not the option for me, because I can't just retrieve language code from url with Regex, I have much more complicated code to define right language code.
Thanks.
What about putting your code in preDispatch? That's what I personally do when I need to check if the person is logged in. Maybe you can move your code there too?

Making GWT application crawlable by a search engine

I want to use the #! token to make my GWT application crawlable, as described here:
http://code.google.com/web/ajaxcrawling/
There is a GWT sample app available online that uses this, for example:
http://gwt.google.com/samples/Showcase/Showcase.html#!CwRadioButton
Will serve the following static webpage to the googlebot:
http://gwt.google.com/samples/Showcase/Showcase.html?_escaped_fragment_=CwRadioButton
I want my GWT app to do something similar. In short, I'd like to serve a different flavor of the page whenever the _escaped_fragment_ parameter is found in the URL.
What should I modify in order for the server to serve something else (a static page, or a page dynamically generated through a headless browser like HTML Unit)? I'm guessing it could be the web.xml file, but I'm not sure.
(Note: I thought of checking the Showcase app provided with the GWT SDK, but unfortunately it doesn't seem to support serving static files on _escaped_fragment_ and it doesn't use the #! token..)
If you want to use web.xml, then I think it won't work with a servlet-mapping, because the url-patterns ignore the get parameters. (Not 100% sure, if there is another way to make this possible.)
You could of course map Showcase.html to a servlet, and in that servlet decide what to do, based on the get parameter "_escaped_fragment_". But it's a little bit expensive to call a Servlet just to serve a static page for the majority of the requests (not too bad, but still. You could set cache headers, if you're sure that it doesn't change).
Or you could have an Apache or something in front of your server - but I understand, I wouldn't like to have to do that either. Maybe your JavaEE server (which one are you using BTW?) provides some mechanism for URL filtering before the request gets passed on to the web container - I'd like to know that, too!
Found my answer! The Showcase sample supporting crawlable hyperlinks is in the following branch:
http://code.google.com/p/google-web-toolkit/source/browse/branches/crawlability/samples/showcase/?r=7726
It defines a filter in the web.xml to redirect URLs with the _escaped_fragment_ token to the output of HTML Unit.

GWT visualization API Motion Chart language

I'm using the gwt visualization library to display motion charts in a gwt app. However, the language shown in the chart is random (different language every time it loads).
This:
http://code.google.com/apis/visualization/documentation/using_overview.html#localization
says I can set it, but only through the load method. But the GWT load method does not allow me to set anything other than the version and Packages.
As far as I can tell, there is no way of explicitly setting the language using the GWT API.
Any ideas?
You can set the locale of a GWT application in many ways: Locales in GWT. My guess would be that the Visualization API uses that value to set its own locale value.
You should be able to do a quick test of this by appending locale=fr (change to your desired locale) to the address:
http://www.example.com/MyGwtApp.html?locale=fr
This will force that locale to be used by GWT.
Update: the AjaxLoader does support setting the language via the AjaxLoader.AjaxLoaderOptions:
AjaxLoaderOptions options = AjaxLoaderOptions.newInstance();
options.setLanguage("fr");
AjaxLoader.loadApi("visualization", "1", null, options);
I'm not sure you can use null for the callback parameter, but you get the general idea.
I've discovered that this is a bug, which I've submitted here:
http://code.google.com/p/gwt-google-apis/issues/detail?id=358

Zend Framework and switching view script paths

I have a problem. Basically, depending on whether a user goes to /es or /br or /cn etc on our website, we have different language template files. So far, we were using a custom templating engine to make this work, but are making a switch over to ZF. I can't seem to figure out how to get ZF to look for a view script in say cn/about-us if the language varuable is cn.
I can't (don't want to) use Zend_Translate for this because we have way too many translated template files and it's just not feasible using Zend_Translate for bazillion different files with multi-paragraphs of Chinese/Korean/Japanese, forgetting for a second that I don't speak those languages.
Can anybody help me?
You can write a controller plugin and use it's routeStartup() method to alter Zend_View settings (path to where your view scripts are located) and change the request uri before routing starts.
class My_Controller_Plugin_LanguageSwitcher extends Zend_Controller_Plugin_Abstract
{
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
// examine the $_SERVER['REQUEST_URI'] and look for your language identifier
// fetch the View and set appropriate view scripts path using setScriptPath() method
// strip the language identifier from your REQUEST_URI
// change the request uri using $request->setRequestUri('your-new-uri-without-the-language- identifier');
}
}