Jump to content

PW 2.4 admin menu not translated


wayne
 Share

Recommended Posts

To make it short:

- I downloaded the latest German language pack from github and installed it

- default.php from AdminTheme module suggests to translate "/wire/templates-admin/default.php" and I checked, it already is

- everything but the admin/backend menu and breadcrumbs is translated

Did I miss or oversee something?

Link to comment
Share on other sites

Hi Radek,

the Czech language pack isn't working just like the German one.

Thanks for pointing to the environment, I will have a look at my setup.

EDIT:

I found the problem. It's the Windows environment and it's backslash pathes.

PW uses the DIRECTORY_SEPARATOR constant in its php code that is a backslash character under Windows.

Basically this is correct. But php isn't quite consistent in that matter.

The translation function gets pathes with normal slashes although the code uses backslashes because of the DIRECTORY_SEPARATOR constant.

The only function that seems to cause that problem is in "wire/modules/LanguageSupport/Languagetranslator.php":

	protected function textdomainString($textdomain) {

		if(is_string($textdomain) && strpos($textdomain, DIRECTORY_SEPARATOR) !== false) $textdomain = $this->filenameToTextdomain($textdomain); 
			else if(is_object($textdomain)) $textdomain = $this->objectToTextdomain($textdomain); 
			else $textdomain = strtolower($textdomain); 

		// just in case there is an extension on it, remove it 
		if(strpos($textdomain, '.')) $textdomain = basename($textdomain, '.json'); 

		return $textdomain;
	}

If you replace DIRECTORY_SEPARATOR with a simple '/', it works.

(EDIT3: That change isn't enough, look at the posts below.)

I don't know if there is a clean solution or if one should write it off as a Windows php quirk.

A quick and dirty fix would be to check for a backslash and a normal slash as directory separator.

EDIT2:

In the subroutine "filenameToTextdomain" I found an existing directory separator fix:

if(DIRECTORY_SEPARATOR != '/') $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); 

But for the problem explained above it comes one subroutine to late.

I think it's now on Ryan to decide where and how to fix that check for the DIRECTORY_SEPARATOR in the "textdomainString" function.

  • Like 3
Link to comment
Share on other sites

  • 1 month later...

in the new dev version this problem is still there.

@ryan: any chance to get this fixed?

================================

EDIT:

tested in the new dev version 2.4.1. When you change this:

If you replace DIRECTORY_SEPARATOR with a simple '/', it works.

the translation for the headings under Setup and Access is broken

post-1027-0-53778700-1395863685_thumb.jp

post-1027-0-84712300-1395863704_thumb.jp

  • Like 1
Link to comment
Share on other sites

the translation for the headings under Setup and Access is broken

Like I said before, the use of / and \ is quite inconsistent. I guess that condition should check for both kinds of slashes under Windows.

Could you try to change

if(is_string($textdomain) && strpos($textdomain, DIRECTORY_SEPARATOR) !== false) $textdomain = $this->filenameToTextdomain($textdomain);

to

if(is_string($textdomain) && (strpos($textdomain, DIRECTORY_SEPARATOR) !== false || strpos($textdomain, '/') !== false)) $textdomain = $this->filenameToTextdomain($textdomain);

?

EDIT:

I tested it, and that works (at least for me).

Link to comment
Share on other sites

  • 1 month later...

Like I said before, the use of / and \ is quite inconsistent. I guess that condition should check for both kinds of slashes under Windows.

Could you try to change

if(is_string($textdomain) && strpos($textdomain, DIRECTORY_SEPARATOR) !== false) $textdomain = $this->filenameToTextdomain($textdomain);

to

if(is_string($textdomain) && (strpos($textdomain, DIRECTORY_SEPARATOR) !== false || strpos($textdomain, '/') !== false)) $textdomain = $this->filenameToTextdomain($textdomain);

?

EDIT:

I tested it, and that works (at least for me).

Testing this bugfix on XAMPP on Windows 8. The 1st level menu gets translated, but not the 2nd. Can we  do something with it?

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...