Jump to content

HUGE issue with Slashes


PWaddict
 Share

Recommended Posts

I transferred a site from localhost (XAMPP Windows) to a live server (Linux) and it's impossible to edit the translations files. When I try to edit for example the LanguageSupport.module I'm getting this error: Session: File does not exist: /wire\modules\LanguageSupport\LanguageSupport.module (translation file not needed? textdomain: wire--modules--languagesupport--languagesupport-module)

I'm guessing the issue is caused because of the slashes:

On localhost the paths for translation files are using backslashes:
\wire\modules\LanguageSupport\LanguageSupport.module

while on a live server the paths are using forward slashes:
/wire/modules/LanguageSupport/LanguageSupport.module

 

Link to comment
Share on other sites

As far as I know, all translations are kept as json files on assets/files folder. I don't think they will be deleted if you uninstall the module. Give it a try but backup the json files first. 

Link to comment
Share on other sites

In order to uninstall LanguageSupport.module I have to first uninstall LanguageSupportFields.module, LanguageSupportPageNames.module and LanguageTabs.module and PW won't let me uninstall the LanguageSupportFields.module because there are fields with multi-language values.

Link to comment
Share on other sites

I found the solution. I have to replace the slashes on each file value from the json files for each language.

This is from localhost:

"file": "wire\\modules\\LanguageSupport\\LanguageSupport.module",

Must be changed to this in order to work on the server:

"file": "wire\/modules\/LanguageSupport\/LanguageSupport.module",

The funny thing is that I changed them on localhost too and they working fine. So the question is why on localhost have been used the 2 backslashes instead of the 1 backslash and 1 forward slash?

Link to comment
Share on other sites

9 hours ago, PWaddict said:

The funny thing is that I changed them on localhost too and they working fine. So the question is why on localhost have been used the 2 backslashes instead of the 1 backslash and 1 forward slash?

PHP's path-related functions return the native directory separator between directories. Since the backslash is also the escape character, it has to be escaped itself to be recognized as a backslash, hence the double backslashes. The backslash in front of the forward slash, while it does no harm, isn't necessary.

Link to comment
Share on other sites

Try adding this:

if(DIRECTORY_SEPARATOR != '/') $data['file'] = str_replace(DIRECTORY_SEPARATOR, '/', $data['file']); 

To /wire/modules/LanguageSupport/LanguageTranslator.php to public function saveTextdomain(), right after $data = $this->textdomains[$textdomain];

Link to comment
Share on other sites

9 hours ago, matjazp said:

Try adding this:


if(DIRECTORY_SEPARATOR != '/') $data['file'] = str_replace(DIRECTORY_SEPARATOR, '/', $data['file']); 

To /wire/modules/LanguageSupport/LanguageTranslator.php to public function saveTextdomain(), right after $data = $this->textdomains[$textdomain];

Same problem.

Link to comment
Share on other sites

7 minutes ago, matjazp said:

You should resave your translations first. Or try with new translation.

I did that and it auto replace the slashes properly but at the same time it erased my translations strings. But that was already happening before editing the public function saveTextdomain().

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