Add translations (switch locale)
Last updated
Last updated
Local setup is required to add translations.
Ensure that you are running "@scandipwa/scandipwa": "x.x.x"
. You can check within scandipwa/package.json
file.
Set up the project locally by following these instructions.
Navigate to scandipwa
folder within your source code folder.
Run command from the terminal npm i @scandipwa/webpack-i18n-runtime
Remove hardcoded locale from app/etc/config.php
file by deleting the following lines of code:
'general' => [
'locale' => [
'code' => 'en_US'
]
],
Open scandipwa/package.json
file.
Add the locales you wish to have and @scandipwa/webpack-i18n-runtime
extension, for example:
"scandipwa": {
"type": "theme",
"locales": {
"en_US": true,
"fr_FR": true
},
"parentTheme": "@scandipwa/scandipwa",
"extensions": {
"@scandipwa/webpack-i18n-runtime": true
}
},
Navigate to scandipwa folder and build your ScandiPWA theme to create added translation files by running the following command: BUILD_MODE=magento npm run start
Add your translations within generated locale file which is located in scandipwa/i18n folder.
Navigate to the repository root folder and run: npm run start
In Magento admin go to Stores > Configuration > General > General > Locale Options.
Switch to your store's scope and change the Locale to the one you created.
Clear cache by going to System > Tools > Cache Management and pressing Flush Cache Storage and Flush Magento Cache.
Open Frontend to ensure that translations are active.
Push all the changes to your repository.
Once the changes are deployed, enable access instance using SSH following these instructions.
Run the following command to enable developer mode: magento deploy:mode:set developer
Change the locale for the store view through your instance admin panel.
Clear cache by going to System > Tools > Cache Management and pressing Flush Cache Storage and Flush Magento Cache.
Run the following commands from your SSH:
magento in:rei
magento c:c
magento deploy:mode:set production