PWaddict

HUGE issue with Slashes

14 posts in this topic

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

 

Share this post


Link to post
Share on other sites

Strange, I didn't have this problem after migrating from Mac to Windows (the other way around). But try uninstalling and installing the module again.

Share this post


Link to post
Share on other sites

But if I uninstall the Language Support module all the language related values will be gone from everywhere.

A temporary solution is to delete all the translations files and find them again.

Share this post


Link to post
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. 

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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];

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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().

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.