The Challenge for New Developers

Multi language website is a big challenge for new developer. They feel that its very hard job to create a multi language website. But in real this job is very easy to handle. I am going to explain in simple steps to handle multi language website.

Before going into much details, I would like inform this is smallest & easiest way to achieve multi-lingual website & only applicable for small scale websites. This may not be 100% optimized way to achieve this but for sure easiest way to achieve this.

The Concept: Using Arrays

Suppose you have a message in website & want to show that in 2 different languages. Store that message in a arrays. For example:

$en_array['content1'] = "Message in English"; $other_language['content1'] = "Message in other language";

How to Implement It

After creating 2 different arrays, you need to assign them to a fixed array that will be used to print content on website.

For example, in your website you are printing message using $message['content1'];.

You don't need to change anything here just set:

// When somebody chooses English language $message = $en_array; // When somebody chooses Other language $message = $other_language;

Now keep adding your content in these language array & print them using $message['index'].

Important Notes

There is one key rule to make this work:

  • You need to keep the index of array same in both arrays.
  • You need to print the same index using the $message variable in your HTML.

That's it! This approach allows you to switch languages dynamically without rewriting your entire page structure.

Ucodice Team

The Ucodice Team is a group of passionate developers, designers, and strategists dedicated to delivering top-tier IT solutions to clients worldwide.