Jump to content

Admin language not working with custom admin theme


Soma
 Share

Recommended Posts

I think for those menu subentries it would be easier to include them in the theme default.php, same like the top menu entries. So they can be translated from the same translation file for default.php.

Since they already have to be translated for the module file, it's unnecessary duplication. Though I'm not opposed to duplication if it makes things simpler/faster for everyone. But since this one is specific to dropdowns in this admin theme (something not in all admin themes), maybe it would be better for it to grab the translated module titles rather than the page titles. Basically like this:

foreach($children as $p) {
 if($p->process) {
   $info = wire('modules')->getModuleInfo($p->process); 
   $title = $info['title'];
 } else {
   $title = $p->title;
 }
 echo "<li><a href='{$p->url}'>$title</a></li>"; 
}

The other advantage of this approach is that it works with any modules, not just ones that have been predefined in default.php.

  • Like 1
Link to comment
Share on other sites

Since they already have to be translated for the module file, it's unnecessary duplication. Though I'm not opposed to duplication if it makes things simpler/faster for everyone. But since this one is specific to dropdowns in this admin theme (something not in all admin themes), maybe it would be better for it to grab the translated module titles rather than the page titles. Basically like this:

foreach($children as $p) {
if($p->process) {
$info = wire('modules')->getModuleInfo($p->process);
$title = $info['title'];
} else {
$title = $p->title;
}
echo "<li><a href='{$p->url}'>$title</a></li>";
}

The other advantage of this approach is that it works with any modules, not just ones that have been predefined in default.php.

That makes sense for the submenus. So the only thing would be if I want to rename it to something different using the page title I can't.

I just took your approach from the default admin theme for the main topmenu item that got defined in the default.php comment.

Link to comment
Share on other sites

I just tested commited an update to the teflon theme, so the submenus get title from module info.

If module is translateable it will work show the language title if it's translated already, otherwise you have to create a translation.

If the module is not translateable you can't.

Link to comment
Share on other sites

Ryan, I noticed something strange. As I translated the Admin pages through the language title, for example "Templates" I had "Vorlagen" in the german title. But when I remove it and make the title field blank it still shows "Vorlagen" instead of default english "Templates". Not sure where this coming from, because there's no such translation present, nor from the ProcessModule translation nor from any other source. It is the page title of admin "Templates" simply. I double checked and put and removed the translations, but it remains, even if I rename it to "blabla" for german and remove it again it again show "Vorlagen".

So after trying I looked into DB and the title "Vorlagen" is still there saved in the page_title field. Sounds like a bug.

Edit: I looked at it again and looked at the page ids. I just noticed it's somehow messing up and taking the default site's "Templates" (1003) page title for the admin "Templates" (11). So I'm a little speechless :D

Link to comment
Share on other sites

I give up. Now I removed the title and all translation for the "Templates" and it still shows "Vorlagen" as the title when I go to Setup->Templates. The translation in ProcessTemplates for module Title is empty. So is the page title for german for both "Templates" pages. DB has no occurence of the word "Vorlagen" and I also emptied cache, but still it remains there magically. :D

Edit: NO really. I found it out.

It looks it's something with my teflon theme. When switch to default admin theme the Title shows "Templates" as it should. BUT when I searched for the word in the theme there's no presents of "Vorlagen", so I found out that the translation of the file /site/templates-admin/default.php had abandoned translations still in there (from testing with adding them in the default.php) from which it took the title even when I deleted them in default.php. Now deleting them from in the translation abandoned ones, it's finally gone!

  • Like 1
Link to comment
Share on other sites

Ryan, I'm still wondering how this can be? I think it's not intended behaviour!?

The string for "Templates" was put in /site/templates-admin/default.php as commented out, same as you did in default admin theme. So the topnav.inc include then can use it.

*__("Templates")

Then I translated it through translater in the file for the default.php /site/templates-admin/default.php

And then "setup/templates" admin page got the title from the translation even though the page title is a language field and empty in german title instance.

Later I removed the string from the default.php but the translation remained even though it's abandoned and the string in template is removed.

How does this come together?

Link to comment
Share on other sites

How does this come together?

Those commented translations in default.php are kind of a placeholder/short cut, and you are seeing a side effect of it. Typically translatable text consists of static text in a file. But the translation being done in this instance is actually on dynamic text. So the commented translation calls are picked up by the parser as translatable copy, but obviously those function calls never execute (since they are commented). Instead, the admin template runs the navigation titles through the translation function, with dynamic text (actual page titles). So if it encounters one of those placeholder words/phrases in a page title, a substitute translation will get used when available.

When you removed the __("Templates") line, ProcessWire considers that abandoned since it no longer appears in the file. But "abandoned" is a runtime state, not a permanent one. That state exists only to notify you during translation time what words/phrases no longer appear in the file. The file still requested a translation for that word "Templates" at runtime, and it found that there was one, so it delivered it. You would have had to delete the abandoned translation to fully get rid of it.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...