SilverCart Forum
We moderate this Forum and we're here to help. Have you already run a forum search to check if your problem has already been solved?
You can help us helping you by providing detailed error messages, screenshots and logfile entries.
Page: 1 | ||
Topic Translation files | 2523 Views |
Translation files
7 December 2011 at 11:21amHi,
I want to make some changes in the translation files. Is it safe to change the settings i.e. in "./silvercart/lang/de_DE.php" ? How are the changes made effective ?
Thanks,
Gerhard
Re: Translation files
7 December 2011 at 12:37pm Last edited: 7 December 2011 12:38pmHi Gerhard,
we already have a documantation for this in our documentation section:
How to implement custom translations to SilverCart
This should provide you all information to modify or add new translations to your project and SilverCart will remain updatable.
Please let me know if you need further help.
Best regards,
Patrick
Re: Translation files
7 December 2011 at 1:36pmHi Patrick,
I just did the changes as described in the Techbase tutorial. I added a function called silvercart_i18n_de_DE_plugin() and did all the appropriate settings for replacing existing translations.
After that I called my application with &flush=all, and nothing appeared on the screen.
So I put everything back to the original state, and translated the strings in the file de_DE.php directly and everything worked fine.
Cheers,
Gerhard
Re: Translation files
7 December 2011 at 2:20pm Last edited: 7 December 2011 2:22pmIf you translate the strings in silvercart/lang/de_DE.php you won't be able to update SilverCart to a newer version without merging these files.
A white screen after a &flush=all indicates that you might have a syntax error in your changes or you called a function which is not available (perhaps misspelled).
Without a syntax error you should see your website with the untranslated strings.
You'll need this line in your mysite/_config.php or your_project/_config.php directory.
i18n::register_plugin('silvercart_i18n_de_DE_plugin', 'silvercart_i18n_de_DE_plugin', 99);
You need to create a lang folder in this directory, too. Example: mysite/lang
After that you can create a de_DE.php file in your language folder and fill it with your translations. This is the example file from our documantation switched to your case (de_DE):
<?php
i18n::include_locale_file('silvercart', 'en_US');
global $lang;
if (array_key_exists('de_DE', $lang) && is_array($lang['de_DE'])) {
$lang['de_DE'] = array_merge($lang['en_US'], $lang['de_DE']);
} else {
$lang['de_DE'] = $lang['en_US'];
}
/**
* i18n plugin to overwrite the default translations for de_DE.
*
* @global array $lang SilverStripe i18n array
*
* @return void
*
* @author Sebastian Diel
* @since 29.06.2011
*/
function silvercart_i18n_de_DE_plugin() {
global $lang;
$lang['de_DE']['SilvercartProduct']['VAT'] = 'GST';
$lang['de_DE']['SilvercartPage']['INCLUDED_VAT'] = 'included GST';
$lang['de_DE']['SilvercartPage']['INCLUDING_TAX'] = 'incl. %s%% GST';
$lang['de_DE']['SilvercartPage']['EXCLUDING_TAX'] = 'plus GST';
$lang['de_DE']['SilvercartPage']['TAX'] = 'incl. %d%% GST';
}
I've tested this on a test installation and it works
fine.
Screenshot:
Maybe you can check your changes to see if something is not like the example.
ciao
Re: Translation files
7 December 2011 at 4:16pmThanks a lot Patrick. I will try this asap and come back to you.
Cheers,
Gerhard
Re: Translation files
7 December 2011 at 5:35pmHi Patrick,
I just did it exactly the way you explained it. But the result is the same as before : white screen.
I cannot see any misspelling or any error.
I created the lang directory in mysite, put in the de_DE.php file containing the function silvercart_i18n_de_DE_plugin(), put the appropriate line in _config.php, ...
I give up.
Cheers,
Gerhard
Re: Translation files
7 December 2011 at 5:59pmHi Gerhard,
normally, a white screen indicates a php error. It seems that your PHP display_errors directive is set to off.
Could you temporarily set it on and check if an PHP error message appears?
Alternatively you should check the php error log file.
Cheers,
Sebastian