Not sure if you figured it out already, but I thought I'd answer anyway..
I guess the other answers are heading in the right direction.
Assuming you already have the translations installed, if not please:
bin/magento i18n:pack -m replace -d source_nl_NL.csv . nl_NL
So, first of all, please clear the cache(as others suggested as well):
rm -rf var/cache var/generation var/page_cache var/view_preprocessed
Secondly, please clear your pub/static folder:
rm -rf pub/static/*/
Then we regenerate the static-content: (I missed the langcode in the other answers..)
bin/magento setup:static-content:deploy nl_NL
- Make sure you add the langcode
Now check if there were any js-translation.json created:
find pub/static/ -name "js-translation.json"
Most likely you'll get a list of js-translation.json
files. Please check these files and delete them if they're empty or contain something like []
.
[UPDATE]
Since Magento 2.2 translation load order is the following:
- Loading the module translations.
- Load translation package info.
- Load theme translation file.
- Load database translation. (Inline translation)
That basically means that translation package will overrule theme translation.
So quick and easy solution would be overcome it using Inline translation, which was also possible in M1.
But we have M2 now which has even more flexibility on board and there is a way to extend existing translation packages with custom ones. All you need to do is create another translation package.
So, create a module
Project\Locale
create a registration.php for it with the following content:
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'project_nl_nl',
__DIR__
);
That's how we define that module is a translation package.
Last step, create a meta-file language.xml with the following content:
<language ...>
<code>nl_NL</code>
<vendor>project</vendor>
<package>nl_nl</package>
<sort_order>10</sort_order>
<use vendor="language" package="nl_nl" />
</language>
This way you specify the parent translation package you want to extend. And also specify the order, in case you already have translation package inheritance in the project.
Here is a link on example from magento itself.
One more thing. Make sure that your <vendor> . '_' . <code>
(from language.xml) will match module name from registration.php
. project_nl_nl
in my example.
Best Answer
Remove /var/view_processed directory.
Delete file pub/static/frontend/Hyp/deboomhut/nl_NL/js-translations.json file.
Deploy static content. After that visit website in browser with Ctrl+F5.
If still now work then open file js-translations.json in browser with Ctrl+F5.
And then visit website.