I have in my template something like that
<h1>Workers {{ 'views.index.list'|trans({}, 'JordiLlonchCrudGeneratorBundle') }}</h1>
And I want to translate this but I don't know how. I guess have to create a file with translations but where save it ,how name a file and what write inside?
In app/config/config.yml I have 'translator: { fallback: "%locale%" }'
In 'symfony/app/config/parameters.yml' defined locale parameter "locale:pl"
First look at the bundle's Resources / translations folder. It looks loke this:
JordiLlonchCrudGeneratorBundle.ca.yml
JordiLlonchCrudGeneratorBundle.en.yml
JordiLlonchCrudGeneratorBundle.es.yml
Then create a file JordiLlonchCrudGeneratorBundle.pl.yml (if you want to translate to the pl local) and put it to the app/Resources/JordiLlonchCrudGeneratorBundle/translations directory.
Use one of the default translation files as a pattern for your translation, translate all text you need and save it to the pl translation file you've just created.
See also: http://symfony.com/doc/2.1/cookbook/bundles/inheritance.html#overriding-resources-templates-routing-validation-etc
Related
I was wondering if it is possible with Symfony 3.5 to use multiple translation files for a single language when using yml files.
Currently I have something like this:
AppBundle/Resources/translations/messages.en.yml
AppBundle/Resources/translations/messages.de.yml
which contains all my translations in either language. However I was wondering if it was possible to change this to the following structure:
AppBundle/Resources/translations/en/products.yml
AppBundle/Resources/translations/en/invoices.yml
AppBundle/Resources/translations/de/products.yml
AppBundle/Resources/translations/de/invoices.yml
I have been looking but I have been unable to find some kind of solution for this. I got it working for splitting up my routes.
AppBundle/Resources/config/routing.yml
appbundle_routes:
resource: '#AppBundle/Resources/config/routing'
type: directory
Inside that folder I got all my routes split like:
AppBundle/Resources/config/routing/products.yml
AppBundle/Resources/config/routing/users.yml
AppBundle/Resources/config/routing/invoices.yml
I was wondering if it was possible to achieve the same thing with translations?
Symfony's Translator requires files to by named in format domain.locale.loader. In case you have messages.en.yml:
messages is the default name of domain, you can also specify eg. invoices
en is the locale
yml is specifying YAML loader will be used
So your proposed use is not possible to achieve with standard set of configs and functionality. However, you can split your translations to different domain files. So paths would be:
AppBundle/Resources/translations/products.en.yml
AppBundle/Resources/translations/invoices.en.yml
And when you are using translator you specify the domain in which the translation should be looked for:
$translator->trans('translated.key', [], 'invoices');
Or in Twig:
{{ 'translated.key'|trans({},'invoices') }}
I need to translate some parts of text to French.
Things I've tried so far:
I created fr.po and fr.mo files in my plugin's /languages directory. I used Poedit for this purpose. I've tried different variants like fr_FR - didn't help.
I added the following to my plugin's main file along with its name and other information:
* Text Domain: pluginname
* Domain Path: /languages
Plugin name does not contain any special characters or underscores/dashes - it's a single word.
Also, tried to use load_plugin_textdomain() function instead (or even along with) to make this work.
Also, tried to add this to my wp-config.php file:
define ('WPLANG', 'fr_FR');
Tried to use any combinations of described actions as well.
I have a string to be translated:
__('Recently', 'pluginname')
The word "Recently" is being displayed correctly but it is not being translated if I change site language. I tried both changing in WP admin panel and adding into config file (mentioned above)
I tried to use get_locale() to check if this was actually changed. This returns 'fr_FR' which is exactly the same with my .po/.mo file names.
**P.S.: ** Checked all these questions and tried all suggested solutions - didn't help:
Wordpress - Plugin translation not working
WordPress plugin translation issue
Wordpress plugins translation
Update: load_plugin_textdomain() returns false if I try to var_dump() result right after function execution.
Actually, the problem was in the names of files. Other than locale name it should also consist of the plugin name, e.g. pluginname-fr_FR.po/pluginname-fr_FR.mo for my case. Yes, this is described in the codex, I should read this more attentively :)
I work with Symfony 4.2
I divided my dir structure, and every part of app is in other folder.
Ex. admin part code is in src/Admin/...
- src/Admin/Controller
etc.
When I set #Template in controller method symfony tell me to situate templates in templates/
But I want to it placed in teplates/Admin/
What I should change in config.
If is other solution than set every action path in #Template(...) ?
Taken from the docs:
# config/packages/twig.yaml
twig:
# ...
paths: ["%kernel.project_dir%/resources/views"]
https://symfony.com/doc/current/configuration/override_dir_structure.html#override-the-templates-directory
This might also be interesting for you:
https://symfony.com/doc/current/templating/namespaced_paths.html#multiple-paths-per-namespace
I can't find it in the documentation : Silverstripe-behat-extension
I have a feature file that has some testing scripts. Now I want to fill some test content in a temp database.
So I create a yml file that puts the content in the database.
But how do I load the yml file in my features file?
In your feature use:
Background:
Given a file "/absolute/path/my-data-fixture.yml"
I downloaded the I18n generator package from: http://codex.wordpress.org/I18n_for_WordPress_Developers#Generating_a_POT_file. I want to generate a pot file for my created template now:
php makepot.php /home/mr/workspace/blog/wp-content/themes/myTheme/ de_DE.pot
After executing this command, I get a de_DE.pot with some the WP standard keys in. But my new keys will not be found. But if I add them to the file manually and upload it, they will be translated.
Why doesn't WordPress pick up all my keys?
I have used the poEdit in the following way.
File Menu > New Catalog
Set the language as per your need. Set utf8
Set the paths as . and ..(if you want to place your .mo file at languages folder).
Define the functions from which the strings to take( ie , _, _e, _n, _x, _ex etc).
Now save the file to your template's folder as templateName.po
Now update catalog.
Upon saving the .mo file will be generated in the same folder.
Now rename the .mo file to the specific Locale (for mine bn_BD.mo, for your case de_DE.mo)
I would suggest a few tips from here