Jump to content


Photo

Admin language not working with custom admin theme


  • Please log in to reply
34 replies to this topic

#1 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 27 March 2012 - 04:52 AM

Hey, I just installed my teflon admin template on a new project (latest PW). I have installed german in the admin.

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 vitor

vitor

    Jr. Member

  • Members
  • PipPip
  • 25 posts
  • 6

  • LocationPortugal

Posted 27 March 2012 - 08:38 AM

That's strange, I'm using your Theme with the latest version of ProcessWire, and it is working for me, for Portuguese.

Just to be sure, did you changed the Language in you Profile / Language also, Soma?

#3 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 27 March 2012 - 08:54 AM

Strange really. Yes I checked the language in the user. I defined the default to be german and uploaded german package. After that I created another one just to make sure.

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 vitor

vitor

    Jr. Member

  • Members
  • PipPip
  • 25 posts
  • 6

  • LocationPortugal

Posted 27 March 2012 - 08:57 AM

I'm lost here, can it be caused by the German translation files?

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 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 27 March 2012 - 09:20 AM

... maybe some server setting issue. I never got that problem, and this project is on a server I've never used.

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 ryan

ryan

    Hero Member

  • Administrators
  • 5,811 posts
  • 3135

  • LocationAtlanta, GA

Posted 27 March 2012 - 11:13 AM

The issue here is the textdomain, which is based on directory + file. Files in /wire/templates-admin/ have a different textdomain than files in /site/templates-admin/ (since 'wire' and 'site' are different dirs). You should be able to resolve it by specifying the textdomain as the second param to your __() calls:

$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 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 27 March 2012 - 11:20 AM

Thanks ryan, thats useful to know, but why does it work in other installs... and servers. I updated my theme like this, so its working without changing something. Or am i wrong and missing something?


***
Ok I think I'm getting old :) It is the same on my local test server. I'm confused as when I updated my theme with the language translation, it was working.

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 ryan

ryan

    Hero Member

  • Administrators
  • 5,811 posts
  • 3135

  • LocationAtlanta, GA

Posted 27 March 2012 - 11:32 AM

Are you including /wire/templates-admin/topnav.inc or outputting your own top nav? If you are including it from /wire/ then the translations in there will still work.

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 :) But that's why I was wondering if you might be including the topnav file from /wire/templates-admin/topnav.inc?

#9 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 27 March 2012 - 11:37 AM

No it's done exact same way as default. It includes topnav.inc from itself not wire.

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 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 27 March 2012 - 11:48 AM

Ok I think the answer is easy :) Uffff it's just that the language pack doesn't really translate the default.php theme template, just the /wire one... so when I create that It should work for the topnav too.

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 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 28 March 2012 - 07:23 AM

Update:

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 ryan

ryan

    Hero Member

  • Administrators
  • 5,811 posts
  • 3135

  • LocationAtlanta, GA

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 


#13 varvanin

varvanin

    Newbie

  • Members
  • Pip
  • 7 posts
  • 0

  • LocationUkraine

Posted 13 April 2012 - 03:15 AM

Tell me as a person not versed in programming to do it. You canfurther instructions? Where do I register textdomain?

#14 vitor

vitor

    Jr. Member

  • Members
  • PipPip
  • 25 posts
  • 6

  • LocationPortugal

Posted 13 April 2012 - 03:30 AM

Hello varvanin,

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 varvanin

varvanin

    Newbie

  • Members
  • Pip
  • 7 posts
  • 0

  • LocationUkraine

Posted 13 April 2012 - 03:59 AM

Youdo not understandme a little, Idid notputnostandard templatefor the administrator.Originallythe originaltemplate,my native language(Russian)workedafter installing thetemplateextinct, not allof theadministration panel.How do Ifix this?Localizationdownloadedon this forum.Andit worked.After installing the themeFutura Remixednot alltranslated.Sorryfor badEnglish

#16 diogo

diogo

    Hero Member

  • Moderators
  • 2,014 posts
  • 1096

  • LocationPorto, Portugal

Posted 13 April 2012 - 04:10 AM

Your English is not bad, it's just a bit glued :)

#17 ryan

ryan

    Hero Member

  • Administrators
  • 5,811 posts
  • 3135

  • LocationAtlanta, GA

Posted 13 April 2012 - 09:41 AM

Varvanin, I'm not sure I understand all points, but if you switch to the default admin theme do you experience the same issue? I'm just wondering if it's something we need to look at in the Futura Remixed admin theme or somewhere else.

#18 varvanin

varvanin

    Newbie

  • Members
  • Pip
  • 7 posts
  • 0

  • LocationUkraine

Posted 13 April 2012 - 10:00 AM

On a standardtemplate, everything works fine.Tell mehow can Itranslatethese words in "Topnav.inc"

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 Soma

Soma

    Hero Member

  • Moderators
  • 3,218 posts
  • 1769

  • LocationSH, Switzerland

Posted 13 April 2012 - 11:09 AM

varvanin, I think the $child_title is not translated because there's no translation for those subpages. I think one way would be to add translation in the default.php like it's done for the main admin pages:


* __("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


#20 Ralf

Ralf

    Jr. Member

  • Members
  • PipPip
  • 29 posts
  • 7

  • LocationGermany

Posted 29 August 2012 - 04:50 AM

@ soma

i´m not 100% sure what about you talking but did that have something to do with your Template and this "translation"-bug??

How can i fix this??

Attached Thumbnails

  • teflon.PNG





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users