Jump to content

Site translation files


alec
 Share

Recommended Posts

 

 

Hello everyone. I have strange things happening when I want to edit Site translation files. When I try to edit files I got error: " Session: File does not exist: /site\templates\include\footer.inc (translation file not needed? textdomain: site--templates--include--footer-inc) "

Here I noticed strange division on left. Somehow it is change direction. Can anyone explain to me why this is happening, and can cause this error?

OnPaste.20160903-172225.png

Link to comment
Share on other sites

  • 6 months later...

I had the same problem.

 

Open your translation file in /site/assets/files/**ID of the language**

My file link was 

 

{
    "file""site\\templates\\home.php",
    "textdomain""site--templates--home-php",
   
     ...

and I deleted the entry in database, changed file name so it created a new one and it corrected to :

{
    "file""site\/templates\/home.php",
    "textdomain""site--templates--home-php",
   
     ...
You can edit your translation files manually.

Now I can edit the translations :)
Link to comment
Share on other sites

  • 1 year later...
On 3/29/2017 at 2:16 AM, bombemedia said:

My file link was

{
    "file""site\\templates\\home.php",
    "textdomain""site--templates--home-php", 
    

Hello,

also the same problem (ProcessWire 3.0.98 ), and solved it with this script.
Maybe it looks dangerous (overwriting translation files) but it's solve my problem.

/*
This script iterate over json translation files and replace 'file' path separator to "\/".
If you want to try it - place it in some template and reload page with that template.
After fix, delete this script.
*/

foreach($languages as $language){
	
	$path = $config->paths->files . $language->id;
	$files = preg_grep('~\.(json)$~', scandir($path));
    
	if( count($files) ){
		
		foreach($files as $file){
			
			// file path
			$file_path = $path . DIRECTORY_SEPARATOR . $file;
			
			// load file
			$contents = file_get_contents($file_path);
			  
			// decode JSON data into a PHP array
			$contentsDecoded = json_decode($contents, true);
			
			if (strpos($contentsDecoded['file'], '\\') !== false) {
				
				$contentsDecoded['file'] = str_replace('\\', '/', $contentsDecoded['file']);
				 
				// encode array back into a JSON string and prettify                
				$json = json_encode($contentsDecoded, JSON_PRETTY_PRINT);
				 
				// save file
				file_put_contents($file_path, $json);
			}		
		}
	}
}

Regards.

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

×
×
  • Create New...