Closed sneetsher closed 7 years ago
Can't you limit {language}
only to go through available languages:
LANGUAGES = (
( 'ar', "Arabic" ),
( 'en', "English" ),
( 'fr', "French" ),
( 'id', "Indonesian" ),
( 'ja', "Japanese"),
( 'ku', "Kurdish" ),
#( 'ur', "Urdu" ),
( 'ms', "Malay" ),
( 'ml', "Malayalam" ),
#( 'tr', "Turkish" ),
( 'es', "Spanish" ),
( 'pt', "Portuguese"),
#( 'sv', "swedish" )
)
Well, I found that firefox have removed defined language tags from the plugin on installation. So pre-defining languages is not possible.
I couldn't get how firefox set the request language. Changing it from about:preferences#content languages didn't work. May be from interface or environment locales, Please , lower the priority of this issue and hold on the code change till I confirm.
Firefox sets the language parameter as his interface language (inherited from environment locale variables).
It will be nice if the user get alfanous results in the browser language by default.
@assem-ch , seems somethings wrong in Alfanous django setup. Documentation says clearly it should fall-back (ex: en-us to en) but alfanous raises 404 error.
Source: https://django.readthedocs.io/en/1.5.x/topics/i18n/translation.html
If a base language is available but the sublanguage specified is not, Django uses the base language. For example, if a user specifies de-at (Austrian German) but Django only has de available, Django uses de.
...
LANGUAGES = ( ('de', ('German')), ('en', ('English')), )
This example restricts languages that are available for automatic selection to German and English (and any sublanguage, like de-ch or en-us).
I will recheck code again see if i can figure it out.
@sneetsher we are using a middleware for localization because django standard does not allow languages that its core not translated yet into
Well, It seems Django i18n supports fall-back xx-YY
to xx
then to default( en
in our case) but only for Accept-Language
user agent header. It does not do same for URL language switch.
I has wrote one for URL but i need to test it more, so it does not break any thing
Alfanous site need to handle the language code in the form of xx-YY. This is needed for OpenSearch standard used for browsers search plugin.
The current state, the site support only xx form for limited languages. Example: http://www.alfanous.org/en/?query=allah
Depending on user configuration the browser insert language parameter as xx or xx-YY. Alfanous need to work for both
Example of URL to be supported: http://www.alfanous.org/en-US/?query=Allah&page=1 http://www.alfanous.org/dd/?query=Allah&page=1
Example from Mozilla site: https://support.mozilla.org/en-US/questions/949545
The new OpenSearch template: template="http://www.alfanous.org/{language}/?query={searchTerms}&page={startPage}"
Here is the update plugin for test: https://addons.mozilla.org/en-US/firefox/addon/alfanous/
Reference: