Admin language not working with custom admin theme
#1
Posted 27 March 2012 - 04:52 AM
For some reason, mos/some of the translations doesn't take effect. For example the topnav stays english.
If I take the default admin theme, it works.
Now, one would think then it's a problem of my admin theme. BUT wait! When I copy the default.php and topnav.inc from the core theme to my theme it still doesn't work. Also I made it multilang a while ago and it was working until now.
What could be the problem? Have you changed anything Ryan recently?
EDIT: tried again, and copied the wire/templates-admin to my site folder and the topnav suddenly doesn't translate anymore. So I guess it's a bug with custom admin themes not being parsed right.
@somartist | modules created | support me, flattr my work flattr.com
#2
Posted 27 March 2012 - 08:38 AM
Just to be sure, did you changed the Language in you Profile / Language also, Soma?
#3
Posted 27 March 2012 - 08:54 AM
But the wierdest is it also doesn't work if I put the "real" admin templates in the site folder.
@somartist | modules created | support me, flattr my work flattr.com
#4
Posted 27 March 2012 - 08:57 AM
Can you try using another language like Portuguese? http://processwire.c...rtuguese-pt-pt/
That's the one I'm using.
EDIT: Nope, I've just downloaded the German language files and it is working ok for me, like I've said completely lost here.
#5
Posted 27 March 2012 - 09:20 AM
But definately doesn't work correctly... just the buttons and some texts, but not the topnav.
Maybe something to do with the __FILE__ thingies.
@somartist | modules created | support me, flattr my work flattr.com
#6
Posted 27 March 2012 - 11:13 AM
$textdomain = '/wire/templates-admin/default.php';
__('text to translate', $textdomain);
I would probably set that $textdomain var at the top of your default.php and then send it as the second arg to all your __() calls. However, if you've got any text translations unique to your theme, you'll want to leave off that $textdomain argument.
#7
Posted 27 March 2012 - 11:20 AM
***
Ok I think I'm getting old
Now it's only the topnav that isn't getting translated, but the other texts (buttons etc) work. Is it because of the inc of the topnav? and the __FILE__ that is there as the domain, and the translation was done on the /wire domain?
SO I need to update my theme again.
Thanks for the help Ryan.
@somartist | modules created | support me, flattr my work flattr.com
#8
Posted 27 March 2012 - 11:32 AM
None of the other translations should pull over from the /wire/templates-admin/ textdomain, since your admin theme is asking for translations with a /site/templates-admin/default.php textdomain. If they were working before, they probably shouldn't have been
#9
Posted 27 March 2012 - 11:37 AM
I'm even more confused now. Could you download my theme and test?
https://github.com/s...admin-theme-pw2
@somartist | modules created | support me, flattr my work flattr.com
#10
Posted 27 March 2012 - 11:48 AM
And the other texts (edit, view... 404 etc )work because they don't have a domain applied? Is that correct?
@somartist | modules created | support me, flattr my work flattr.com
#11
Posted 28 March 2012 - 07:23 AM
So there's a slight problem now with this, in that all language pack maybe missing this translation in case someone uses custom admin theme. THe topnav won't get translated if there's no translation added for /site/templates-admin/default.php.
It can be created quickly, but if someone doesn't know the language it's a little difficult and cumbersome.
Can we do something about it that will choose the /wire/templates-admin/default.php ? Or urge the language packes creator to have this included?
@somartist | modules created | support me, flattr my work flattr.com
#12
Posted 28 March 2012 - 09:26 AM
And the other texts (edit, view... 404 etc )work because they don't have a domain applied? Is that correct?
Those work because they are coming from a different file. The only translations that won't come through to /site/templates-admin/default.php are those that are defined in /wire/templates-admin/default.php. The intended way to pull a translation from another textdomain is to specify that as the second param to the __() function, like this:
__('logout', '/wire/templates-admin/default.php');Rather than having to type that into every __() function call, I recommend just putting it in a variable at the top of your file:
$td = '/wire/templates-admin/default.php';
And then just doing your calls like this:
__('logout', $td);So if you were copying over the /wire/templates-admin/default.php into /site/templates-admin/default.php, then I would just change all the __('text', __FILE__); to __('text', $td);
This is only worthwhile for instances where the untranslated text is going to be exactly the same between the one in /wire/ and the one in /site/. If you are adding new/different translatable text to your custom admin theme, then no need to have it reference PW's default admin theme, as that text won't be translated there. So for those instances, you would just do this:
__('new text to translate');
__('new text to translate, __FILE__); // same thing: less pretty, slightly more efficient
#14
Posted 13 April 2012 - 03:30 AM
Everything you need to know about Multi-Language Support is covered very well here: http://processwire.c...nguage-support/ it is a great read, please check it out, and if you still have doubts, post them here.
Rest assure that you don't need any programming to do it
Best
#15
Posted 13 April 2012 - 03:59 AM
#18
Posted 13 April 2012 - 10:00 AM
if($showItem) {
$class = strpos($page->path, $p->path) === 0 ? " class='selected'" : '';
$title = strip_tags((string)$p->get('title|name'));
$title = __($title, dirname(__FILE__) . '/default.php');
echo "\n\t\t\t\t<li><a href='{$p->url}'$class>$title</a>";
if(count($p->children()) > 0 && $p->id != 3){
echo "<ul>";
echo "<span class='arrow'></span>";
foreach($p->children as $child){
if($child->viewable()) {
$class = strpos($page->path, $child->path) === 0 ? " class='selected'" : '';
$child_title = strip_tags((string)$child->get('title|name'));
$child_title = __($child_title, dirname(__FILE__) . '/default.php');
echo "\n\t\t\t\t<li><a href='{$child->url}'$class>$child_title</a></li>";
}
}
echo "</ul>";
}
echo "</li>";into my language. With other matters handled.
How to translate $child variable?
#19
Posted 13 April 2012 - 11:09 AM
* __("Pages");
* __("Setup");
* __("Modules");
* __("Access");
* __("Admin");So it can be added though the default.php, and the topnav.inc will get it from there.
I don't know if there's another way. Ryan?
@somartist | modules created | support me, flattr my work flattr.com
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













