- This topic has 5 replies, 3 voices, and was last updated 11 years, 2 months ago by
toemmy.
- AuthorPosts
- February 22, 2015 at 7:09 pm #10003178
toemmyParticipantHi,
Pie Register is a really great plugin.
I am about to translate it to german. At least the frontend textes.
Is there a possibility to translate the country dropdown box in the address section of registration form?
There are Strings for all Countries in the .po File, but translating them has only an effect in the backend, when choosing the default language, not in frontend.Any hint would be appreciated.
Thanks in advance,
Toemmy.February 24, 2015 at 4:38 pm #10003188
Pie RegisterParticipantYes, you can translate all text including the country list using PO/MO file.
Thanks
June 5, 2015 at 6:04 pm #10003588
evani2003ParticipantHey,
I have the same problem. How did you solve it?
Thank you!
Eva
June 6, 2015 at 6:56 pm #10003592
toemmyParticipantHi Eva,
unfortunately there isn’t an easy solution without making some modifications to the plugin code.
I checked the Plugin Files and the countries aren’t translated in other languages before they are displayed in the dropdown box.
So I had to add some code to the plugin myself (registration_form.php, around line 450).The way I did it was going through the $countries array and translating every entry to the given language:
$countries_t = array(); for($i=0; $i<sizeof($countries); $i++){ $ct = __($countries[$i], "piereg"); array_push($countries_t, $ct); } sort($countries_t); $countries = $countries_t;Of course it makes sense to put this code in an hook, so you don’t have to rewrite the whole code again after a plugin update. And you still have to translate the country strings in the .po files.
Hope I could help.
Cheers,
Toemmy.June 9, 2015 at 5:16 pm #10003608
evani2003ParticipantThank you a thousand times!
My boyfriend helped to optimize it. Use this code instead of yours in your functions.php and you will have no worries about updating:
add_filter( 'option_pie_countries', 'eva_translate_countries_option' ); function eva_translate_countries_option ( $countries ) { $countries_t = array(); for($i=0; $i<sizeof($countries); $i++){ $ct = __($countries[$i], "piereg"); array_push($countries_t, $ct); } sort($countries_t); $countries = $countries_t; return $countries; }🙂
June 9, 2015 at 7:23 pm #10003609
toemmyParticipantVery nice! Thanks a lot!
I didn’t notice that I could add the filter to get_option directly. - AuthorPosts
- The forum ‘Installation’ is closed to new topics and replies.
