I'm trying to change locale in the plugin that is used as a theme.In my AppController I set the locale with:
I18n::locale('bs');
And in the plugin that is named 'Admin' I place the translation file in this location:
Admin
/src
/Locale
/bs
admin.po
Locale does seem to change, but it doesn't fetch the translations from the translation file. What could be the problem?
The problem was I wasn't using domain name while translating strings. You need to use __d() with the name of your plugin as the domain.
Related
i wrote a plugin (AdminView) as a theme and i want to localize it.
i generate pot file using
bin\cake i18n extract --plugin AdminView
the pot file created by bake at
root/plugins/AdminView/src/Locale/default.pot
i moved it to
root/plugins/AdminView/src/Locale/fa_IR/default.po
and i set the locale to fa_IR
but cakephp dose not load it .
but when i move files to the
root/src/Locale/fa_IR/default.po
it loads perfectly.
the question is how can i load po files in the plugins directory ?
i cleared the root/tmp/cache/persistent every time i test
As mentioned in the comments, plugins cannot provide messages for the default domain unless their paths are included in your apps App.paths.locales config, or a custom loader is being defined for the default domain.
By default, plugins provide translations for their respective plugin domain, ie for AdminView that would be admin_view (admin_view.po or .mo accordingly), and you'd use it like __d('admin_view', 'message').
If all your translation function calls are inside of the plugins, then you should probably stick to the convention, and use the respective plugin domains, which you can always override at application level, or provide fallbacks for in your app level default.po.
See also
Cookbook > Internationalization & Localization > Language Files
Cookbook > Internationalization & Localization > Using Translation Functions
I am trying to implement Localization in Ext JS using Sencha CMD using version 5.0.
I have added locale folder and corresponding content in that. I have modified app.json with locales and builds object and added output object based on which different bootstrap json will be built for each build configured in build object.
Not when i do sencha app build and then open the Appname/index.html and change locale via url i am able to achieve localization.
But when i open Appname/build/production/Appname/index.html and change the locale in url i am not able to change the app language by changing locale in url.
Any advise on how to go about it.
Let me know if you need more information.
Like most js web apps we have a config.js file that contains global config information about the app, base api urls and such. These values are often different in local development than in production.
I've looked at answers like: Development mode for AngularJS using GruntJS, and also things like grunt-replace for creating an on-the-fly config file.
My issue is that the "development" part varies from developer to developer, we all need a version of the API setup so the base api urls will be different. I'd like to allow each developer to override specific variables in the config in a way that doesn't require them to commit that info to the git repo (I agree that this isn't best practice, everything should be in the repo, but as this is only 1/2 variables for this project I can overlook it)
Any ideas on how to achieve this setup?
You can use grunt-preprocess. I would have production (and dev-server, etc) values in a file, say env.json. You could use grunt to look for an optional file, say overrides.json or developer.json, which would extend/overwrite the values from env.json.
var envFile = require('./env.json');
You can create command line options to grunt with grunt.option, e.g. var env = grunt.option('env') || undefined;, which could be used to turn off overriding.
You can get data from the optional file using fs.existsSync:
var fs = require('fs');
var developerFile;
if (fs.existsSync('./developer.json')) {
developerFile = require('./developer.json');
}
The simplest way to define the grunt-preprocess context would be to use the developer.json file if present, or the env.json file if not:
context: developerFile ? developerFile : envFile;
This requires the developer file to be complete. An alternative is to extend the envFile with options from developerFile if it's present.
In my project, we use different config files (which are basically files with JS object). So every developer has his app/configs/developer/config.js file, which is not comited in the source control, so every developer has his own setup. Project uses link to app/scripts/config.js by default and this file is just a soft link to developers config file. However, there are also app/configs/staging/config.js and app/configs/production/config.js files, which are replaced when using gruntjj to build project. Those configs are just copied to build solution instead of soft linked file.
I hope that makes sense..
I am using cake i18n,
when it creates the file default.pot there are also strings of the plugin.
How make to exclude the folder plugin from cake i18n?
The good solution will be using __d() function with prefix of name of plugin.
or
In CakePHP i18n shell You can exclude folders.
I have this error, When i import .po file in drupal admin panel,
Configuration » Regional and language » Translate interface
Error: File upload error. Could not move uploaded file.
Error: File to import not found.
Anybody know how to rectify this error...
I found a way to do this using Drush and Localization Update.
Install Localization Update
Configure a local path for po-files (admin/config/regional/language/update)
Configure automatic updates from remote servers or just local sources
Now you can put your own po-files in a local path (for example sites/all/translations). If you have translations for your own module then you name it according to this naming convention:
modulename-version.language.po
So a Swedish po-file for 'my_module', version 7.x-1.1 would be named:
my_module-7.x-1.1.sv.po
Now you have everything setup and you can start updating your sites translation with Drush:
drush l10n-update-refresh // Looks for new po-files
drush l10n-update // Updates translations