Jump to content

PHP import/export language packages?


douphp

Recommended Posts

Hello,

 

I need a little help with exporting data from a database that contains language packages.

 

To explain in short I have a small PHP script that is multilingual and all the phrases are stored in the database. It currently can export the phrases for a specific language package and it can also import the exported data. So it allows the usage of other language packages in the future.

 

It works great with the default language package I have setup, which is English; however I am having problems with other languages such as Polish, Greek, Russian etc... When I export the data and then try to import the data using my script all the special characters turn into question marks.

 

Since the exported data is in a flat PHP file I use PHP fwrite to write to the file. I tried to use PHP's utf8_encode, however that did not do much help. I also tested to change the collation of the database, which also did not help.

 

So I am rather lost as to how scripts like vBulletin can export language packages and then import it, while dealing with character issues.

 

Any help would be appreciated.

 

Thanks

Link to comment
Share on other sites

You must set the encoding of the database as UTF-8 and the database fields as UTF-8_General_CI

Your PHP page you must save as UTF-8, and in the HTML Header, you must set the content as UTF-8.

 

It should work.

 

But for a test, you can just set the page character manually by pressing in your browser: View->Character Encoding->Unicode (UTF-8)

or whatever encoding you will use.

Link to comment
Share on other sites

Thanks for the reply.

 

I tested to change the collations (encoding) for the database and database fields. I tried "UTF-8_General_CI" amongst others. I also have it set in the HTML header as UTF-8. When printing the exported data I can see the correct data, however when saving it to a PHP flat file this is what is causing me problems. The reasons I am saving it to a PHP flat file is so I can import the data at a later time.

 

Link to comment
Share on other sites

I believe I got it working. I had to add this at the top of my script:

header('Content-Type: text/html; charset=UTF-8');

Funny thing is it worked fine on one server without it, while on another server it did not which was the one I was developing on. In any case having that in the script helped me to get it working on both servers and for different languages.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.