mantissa
mantissa

Reputation: 145

How Can I Develop Multilingual Web Application

I have developed a multilingual web application with Asp.Net. I want to a question for this.Should i use Globalization or Cookie?Which one is true selection?

Upvotes: 0

Views: 2130

Answers (2)

Ishtiyaq Husain
Ishtiyaq Husain

Reputation: 424

This is how I am creating multilingual website.

Code Language: PHP

Directory Structure:

/
|- core
|  |- init.php
|  `- lang
|     |- en_US.UTF-8.ini
|     `- hi_IN.UTF-8.ini
|
`- dashboard.php

Language Filename: en_US.UTF-8.ini

[Headers]
HEADER_DASHBOARD = "Dashboard";
HEADER_USERS     = "Users";
HEADER_GROUPS    = "Groups";
HEADER_HELP      = "Help";

[MainMenu]
MENU_DASHBOARD = "Dashboard";
MENU_USERS     = "Users";
MENU_GROUPS    = "Groups";
MENU_HELP      = "Help";

Filename: init.php

<?php
$available_lang = [
         'en' => 'en_US.UTF-8',
         'hi' => 'hi_US.UTF-8',
      ];

//check if requested language is available or fallback to default.
$language = (isset($available_lang[$_GET['ln']])) ? $available_lang[$_GET['ln']]:'en_US.UTF-8';

$_SESSION['language'] = $_GET['ln'];

$ini = parse_ini_file("/core/lang/" . $language . ".ini");
?>

Filename: dashboard.php?ln=en

<?php
require_once 'core/init.php';

if ($_SESSION['language']) == 'en') {
    echo '<a href="?ln=hi">Hindi</a>';
} else {
    echo '<a href="?ln=en">English</span></a>';
}

// example uses
echo $ini['HEADER_GROUPS']; // Dashboard
?>

Upvotes: 1

Jigar Pandya
Jigar Pandya

Reputation: 5977

Globalization would be a better option... you can create language specific resource files to do multilingual web apps.

You can check

http://www.codeproject.com/Articles/7998/Creating-multilingual-websites-Part-1

Best way to implement a multilingual in ASP.NET application

for better understanding.

I strongly recomend to use Resource Files and Some resources are:

Walkthrough: Using Resources for Localization with ASP.NET

How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization

Upvotes: 1

Related Questions