Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Viewing and Modifying Japanese?


asdowdel

Recommended Posts

Posted

I have installed the Japanese language pack. When I open up the japanese.php file, all the Japanese looks like ancient Egyptian hieroglyphics. When going to the "file manager" in tools on the admin page I can then go to "view" in the web browser and select "Character Encoding" -> "Japanese EUC" and it will properly display the Japanese. The issue is that I cannot modify it. I have changed my permissions for file_manager, configuration, configure, index, japanese.php all to 777 and I still get a 403 forbidden message when trying to save the changes I've made. To be more specific I get, "You don't have permission to access /oscommerce/catalog/admin/file_manager.php on this server."

 

How do I modify this in file manager?

Is there different program that will let me view the Japanese coding and modify it?

Posted

DON'T USE file_manager.php OR define_language.php! They are terrible security exposures and those files should be ERASED immediately!!!!!!

 

NO file should be 777 permissions. Ever. A file should be 644 (or 444 if necessary for configure.php files to silence the "I can write to..." warning). Directories should be 755, except possibly 775 or (temporarily 777) for selected directories where osC needs to write files to it. Read my sig > FAQs > Proper Permissions.

 

If you download Japanese language files, you have to know what character set encoding they are in. There is UTF-8 and there are a number of single-byte sets. If you are remotely editing (using a browser, with the file on the server), watch the character encoding at all levels, and check that your browser has the appropriate fonts. If you FTP the file down to your PC, watch out for what encoding your PC is -- it will need to match the file (and of course, you need the right fonts). You say that characters look like hieroglyphics -- are they little boxes with 4 hexadecimal digits in them? If so, you're trying to display the file in UTF-8, but don't have the Japanese fonts (Kanji, Katakana, Romanji, etc.). If they're just bizarre non-Western (non-Latin) characters, are you sure you're not actually seeing the correct Japanese text? What are you expecting to see?

Posted

MrPhil

 

Thanks for the tips. An example of what I'm seeing is: define('HEADER_TITLE_CREATE_ACCOUNT', '¥¢¥«¥¦¥ó¥ÈºûÜ®');

 

From what I've discovered this far is I can view the above properly by selecting the Japanese EUC encoding in the browser. I don't have a program that lets me edit from the browser though. As far as I know, I can't change notepad to the Japanese EUC charset. For most of what I'm doing I use phpDesigner 7 which I cant use the Japanese EUC coding. Basically I need to view it in Japanese EUC but save it in ANSI to work properly with oscommerce correct? How do I do this?

Posted

The Japanese text (EUC encoding?) is being displayed in some other character encoding, such as Latin-1 or Windows-1252. What are you trying to do when you say "save it in ANSI to work properly with oscommerce"? That makes no sense. You edit and save a language file in the same encoding (e.g., EUC) as will be used to display the page on the browser. You can't edit in one encoding and display in another, or you'll get the problem you see.

 

Note that some editors are stupid and save extra information, which will break your site. Microsoft editors are notorious for adding the "UTF-8 Byte Order Mark" at the beginning of files when they think you're editing in UTF-8 mode. Just keep that in mind if you start seeing odd characters show up on the screen, and "can't modify headers" error messages.

Posted

MrPhil,

 

The website itself displays the Japanese correctly however, the php file, saved in ANSI encoding, does not display the Japanese correctly. I have tried saving the php file as a UTF-8 and on top of not being able to read the Japanese in the php file, it then changes the website to some unreadable script.

 

I have figured out how to properly view the Japanese in the PHP file using another forum post. I downloaded a trial copy of dreamweaver, opened the japanese.php file, on the menu bar went to Modify -> Page Preferences -> Title/Encoding, and changed the encoding to Japanese EUC. Since I could then see the Japanese correctly, I modified the text I needed to, went back and changed the encoding back to Western European, saved, and now it also displays properly on the website.

 

If there is a way to do this outside of dreamweaver that would be excellent. Otherwise it looks like after my trial period is up I'll be forking over some cash to purchase dreamweaver.

Posted

In order to edit the file (encoded Japanese EUC), you will need to have some sort of editor that displays such text correctly. You've found Dreamweaver, but perhaps there are other solutions. One might be to leave the file on the server and access it by a browser. At worst, you could make a PHP page that just has a big <textarea> tag with the PHP file read in as the default value string, and the page writes out to a file. So long as the page is displayed in EUC-JP charset, and your browser has the necessary fonts, it should render correctly. If you just need to do minor text changes, that might be adequate. Just make the script name hard to guess, so people don't use this tool to corrupt your store! Otherwise, you need to find a PC editor that handles the file correctly, or a way to temporarily switch your PC to that encoding.

 

I'm not sure what you mean by ANSI encoding. Do you mean "Western" Latin-1? I don't know why you would need to switch back to "ANSI" before saving the file, but maybe DW is inserting something odd if you don't? Your PC, your FTP upload, and your webserver don't care what encoding a file is... as far as they're concerned, it's just a long stream of bytes and they don't know (or care) what the bytes mean. It's only when it comes time to interpret the contents as a PHP file, and then send it on to the browser, does anyone care what encoding was used.

 

Here's a Quick n Dirty editor I just tossed off, that runs on your server (access via browser):

<?php
// a Quick and Dirty file editor to be run on your web site
// give it an obscure name that no one will guess
// (c) copyright 2010 Phil M Perry
// license: GNU Public License (GPL)

$file = $_REQUEST['file'];  // properly escaped file path and name
// mode=edit OR mode=save. user would only use edit
if (isset($_REQUEST['mode'])) {
$mode = $_REQUEST['mode'];  
} else {
$mode = 'edit'; // default
}
// 'content' only on internal call (mode = save)
// 'submit' = save or cancel
$self = $_SERVER['PHP_SELF'];
$char = 'EUC-JP';  // hardcoded Japanese for now
?>
<html>
<head>
<title>EUC edit: <?php echo $file; ?></title>
<meta http-equiv="Content-type" content="text/html; charset=<?php echo $char; ?>" />
</head>
<body>
<?php
if ($mode == 'edit') {
// get $content (error if none found)
$content = file_get_contents($file);
if (strlen($content) == 0) {
	die("unable to read file $file, or was empty");
}
?>
<form method="post" action="<?php echo $self; ?>?mode=save&file=<?php echo urlencode($file); ?>">
<textarea name="content" rows="24" cols="120"><?php echo $content; ?></textarea>
<br /><input type="submit" name="submit" value="Save" />
<input type="submit" name="submit" value="Cancel" />
<input type="reset" />
</form>
<?php
} else { // $mode = save
$content = $_REQUEST['content'];
if ($_REQUEST['submit'] == 'Save') {
	// write $content back to $file
	$len = file_put_contents($file, $content);
	echo '<h2>File saved</h2>';
	echo "<p>$len bytes written.</p>";
} else {
	echo '<h2>File unchanged</h2>';
}
}
?>
</body>
</html>

It's probably not very robust, but could do for simple edits. Be sure to name it something obscure, and try it out on some not-too-valuable file. It's a bit clumsy... you need to enter the path and file "URL safe" encoded (e.g., %2F instead of / in a path), with file= for the file. It's PHP 5 only (file_put_contents call), so will need some revision for PHP 4. It could be extended to permit a char= parameter to give the character set used, and show line numbers. Since you can 'cancel' an edit, it can be used as a read-only browser. If you need to edit a file that contains the text </textarea>, you'll need to do something to disable tags using htmlspecialchars() for edit, and put them back upon save.

 

See if it does the job for you and saves you from having to buy Dreamweaver!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...