Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Monday, June 13, 2011

Internationalization in PHP


Our current game plan with First EMT is to build a Javascript and PHP web application so I've been looking at ways to do internationalization in PHP. If you're writing code that needs to be accessible in many different languages, internationalization is a must. Instead of hard coding text you create a variable for every body of text in your interface. Then you store translation files for every language your UI must support. By changing your locale variable you can quickly and easily switch the language your UI displays. If you make the translation files human readable it is also very easy to add new languages by simply hiring a professional translator for a few hours of work.

My first searches seemed fruitful... I found this documentation describing Resource Bundles. It seemed great until I noticed it was under the header "Future Directions". I'm a fairly proficient programmer but I'm certainly not ready to write a patch to PHP... time to look at other options...

The best option I've found so far is called Zend_Translate. Zend's translate framework is really flexible. You can provide something as basic as arrays of words to translate or as complex as importing a Translation Memory file and dynamically translating everything. For my purposes I think I'm going to use the TMX adapter. TMX is an extension of XML and it's an industry standard for this sort of application. It can be modified in any XML editor which makes it very easy to add new translations. An example TMX file would be something like:


  1. <?xml version="1.0" ?>
  2. <!DOCTYPE tmx SYSTEM "tmx14.dtd">
  3. <tmx version="1.4">
  4. <header creationtoolversion="1.0.0" datatype="winres"segtype="sentence"
  5.         adminlang="en-us" srclang="de-at" o-tmf="abc"
  6.         creationtool="XYZTool" >
  7. </header>
  8. <body>
  9. <tu tuid='message1'>
  10. <tuv xml:lang="de"><seg>Nachricht1</seg></tuv>
  11. <tuv xml:lang="en"><seg>message1</seg></tuv>
  12. </tu>
  13. <tu tuid='message2'>
  14. <tuv xml:lang="de"><seg>Nachricht2</seg></tuv>
  15. <tuv xml:lang="en"><seg>message2</seg></tuv>
  16. </tu>
  17. </body>
  18. </tmx>


This example is straight from the Zend Framework website.

Monday, January 24, 2011

PHP mini-project Update

I hit a small roadblock this weekend trying to get file uploading to work. That plus my AI homework really slowed down the project. I'm still banging away at it. Today I managed to get uploads to the web server. Next steps: Get the uploads to the right place. Password protect it! (O_O) Then I'm going to get the app pushing information to a database. From there I'll get the front page of the website reading information from that database.

Thursday, January 20, 2011

PHP: Photo Hero Project

So I'm the webmaster of the RIT Rock Climbing Club. What this basically means as far as the club is concerned is that I'm the only one that knows what a terminal window is. I figure since I know a thing or two more than that I should write some code to help future members of the club. So here's my idea:

Right now the club's front page has a slideshow of club members doing club-y stuff.(link) The members of the club wish to be able to change the images in the slideshow from time to time. Right now the current system is for them to send me an image. I crop the image to the right resolution and send it server side using sftp. Then I have to modify the index.php file to include the new image + alt text. The final step is using RIT's web manager to push everything to the production server. This is all really basic and easy since I program. However in the future the club might not have a programmer available to do this.

My goal this weekend is to create a web interface for uploading and deleting images from the slide show. This should allow club admins to easily modify the front page of the website.

Goals:

  • Simple web interface to upload and delete images from the server
  • RIT LDAP authentication using a database of admin user names
  • Database storing image location on server + image information (photographer, alt text, etc)
  • modified index.php with generic data structure filled with info from the database
I only have passing knowledge of both PHP and SQL so this whole project should be rather interesting. I don't think it's going to be incredibly hard. Most of the work should be researching how to do the things I want in PHP.

Useful links: