Developers
Texts and Translations
The interface contains several messages that are displayed along the user's purchase experience. These are not content that can directly be edited in the database. To change them, there are two methods, dependent on 3 scenarios for each piece of text, each with its interface.
It should be removed.
Removals should be done using CSS to hide the element that contains the text.
It needs changing.
Changing the text can be done by translating and replacing the compiled versions of the POT file, present in plugins source.
An additional text is needed.
This can be achieved like the previous point, although this change would mean a new file for a new locale.
Included translations
For internationalization, we only support the following languages at the moment:
pt-PT, Portuguese (Portugal)en-US, English (United States of America)
Custom translations
The application is front-end based, using JavaScript as the main language. Due to this the translations should follow the logic that JavaScript translations have in WordPress.
The translations files are in the JED 1.X format (learn more about custom JS translations). The basic file structure is as follows:
Translations domain
The application code uses the frontend translation domain, which means the domain and JSON property with this value are required and can't be changed.
{
"locale_data": {
"frontend": {
"": {
"domain": "frontend",
"lang": "eo",
"plural-forms": "nplurals=2; plural=(n != 1);"
},
"Simple Block": [ "Simpla Bloko" ],
"Hello World": [ "Salunton mondo" ]
}
}
}
Translation file names
The name follows a special structure for WordPress to locate which translations to load. In our case the structure is more restricted than the on mentioned in the documentation due to the fact that the translation domain and the script handle are fixed. All files should be names as follows:
frontend-${locale}-admira_wp_plugin_frontend.json
You may only set different files for different locales. To set translations for pt_PTthe file name would be: frontend-pt_PT-admira_wp_plugin_frontend.json.
Replace translations
To replace a translation file the admira_wp_plugin_frontend_translations_path filter should be used. With this filter a new languages folder can be set, where the new translations file (or files) will be located.
The following example assumes the new translation files will be located in the theme's languages/ folder.
add_filter( 'admira_wp_plugin_frontend_translations_path', function ( $old_translations_path ) {
return get_stylesheet_directory() . '/languages'
} );