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
Related
I'm using "react-i18next" to translate my Website and the translation files are in "/public/locales/{en|fr}/translation.json".
Problem: the files are cached and therefore when I update the translation values, the changes are not applied except if I clean my browser caches.
I guess, the solution is to add a hash in the name of these translation files during the start/build. This is what React already does for files in '/src' folder. How can I achieve that ? It seems that 'react-scripts start/build' abstract all the Webpack configuration.
You can host your translations on a dedicated path with the help of i18next-http-backend, like described here.
Alternatively, you could also make use of a professional CDN service like locize and fetch the translations via i18next-locize-backend, like described here.
I am looking for a solution that works with hugo server command. I am aware that I could create an additional .css file inside static/css directory and have it merged into the public directory with hugo command, however that does not work with hugo server unfortunately.
Thanks in advance.
On Hugo Pipes, you have an example with "Hugo Pipes Revolution -- A Hugo built-in asset pipeline" from Regis Philibert to give some examples.
From now on, Hugo will take care of bundling, minifying, fingerprinting our assets and even compiling our sass files! All of this without any external build tools.
So it works with hugo server.
You can define your method in assets:
These methods will only be available on files living in the assets directory: think of it as a static directory except the files will not be published by default.
Much like its static counterpart:
Its location is configurable with the assetDir key of your config.yaml. (will default to assets)
It follows the Hugo’s file unison logic.
Meaning, anything in your project/assets will override homonymous files of your theme/assets.
From there, you can adapt one of the sass centering techniques to apply it automatically on your images using pipes.
See "Centering With Sass".
I am using sencha cmd 6 for building my application.
my folder structure is
classic
src
model
view
account
jobs
portal
portal.js
controller
store
production build process execution is successful but when i load that build its giving .js file not found error.
So i include all js files in folder structure into main js portal.js then .js error is removed and build works.
But i dont want to include all these list of files in one single js, so can we skip the js include part from portal.js and use any property or attribute to include all js files ?
You can specify with * like 'Ext.chart.*' in requires section of Ext.app.Application.
Hope this helps.
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.
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..