Multilingual Data Display/Edit/Delete UI? - c#

I'm developing a Multilingual website, and I used the following database design approach to build my data structure.
Products
===========
ID
NameResID
DescResID
Price
Resources
===========
ID
ResID
Text
LanguageID
Languages
==========
ID
LanguageName
UserLanguages
===============
ID
UserID
LanguageID
IsDefault
As far as writing the cruds, I wrote all of them, with support of languages.
Now the main issue is backend related, how to Display/Edit/Delete in a nice UI given the following scenario:
User logs on > Adds English and French... as his user languages while having English as his default language, since English is now default when the user goes to add a new product, the product is created and the resources are saved in English, perfect, now the user can change the language to french to add translations for that same product added and also the user can Add a new product in french and when I switch back to English, I can edit its translation in English as well.
What I'm doing right now (picture below) is basing everything on English, and I want to be able somehow NOT to base on English nor the default language cause even the default language can change, I thought of adding a reference name, but I didn't like that approach.

On first brush with this issue, it seems to me like you should just make the language a selectable option at the time of data entry. You can default it to whatever the user's current default language is of course, but it seems like a pain to have to go change your global language preference to enter another language.

Related

Multi lingual site for one country

I have a requirement where I have a site and the user enters the product information from an administrative end.
One of the mandatory requests is to select a country for the product before the user can save the product.
When a public user arrives at the site they need to have the option to swap between the languages. So if I arrived to the German site and want to view the site in English I should be able to change from German to English (and back to German).
I have the resource files created (German) however how do I swap between the two languages. I appreciate I may need to tweak a little more but if I can get onto the right track I can take it/question from there?
First you ensure you save the data in the correct encoding in your database by configuring the data collation for each language, and save it in the correct datatype.
To do that you must do the following :
Database
Ensure the column or database collation is defined to the targeted language read more about it SQL Server, Oracle, MySQL
Ensure the column datatype is designed to accept Unicode characters. (if you save some text, it should show it as is).
Application
in your ASP.NET Application, you ensure that you read these data from the database with the correct encoding ( UTF-8 is a common encoding for the web, but sometimes you might need to use ASCII or Unicode then convert it back to UTF-8 depends on the language you're dealing with).
After ensuring the string encoding. You can now use it on your ASP pages, you only need to control the page language you have two options.
Option 1 : Use Javascript to translate the page to another language dynamically using html lang attribute.
Option 2 : Use .NET Globalization by defining the translations using resources files more in that in this link

How to determine default language for multi lingual countries

I'd like my website (c#) to detect visitor's country and present the website in their local language. This is straight forward for the most part but I've run into problems for the following countries:
Canada
Switzerland
Taiwan
All of which have at least two languages being spoken.
I was wondering if there are ways to detect the language preference for visitors from these countries.
I've thought of a couple of things:
Region based detection, pinpoint which region of the country are they from by capturing IP.
Detect the visitor's OS language and replicate that.
If you have other ideas I'd greatly appreciate it. How does other website do this?
It depends from framework and language (of programming) that you use.
For example in pure PHP there is variable $_SERVER with property 'HTTP_ACCEPT_LANGUAGE', example of usage in the link below:
Detect Browser Language in PHP
In Symphony you can configure translator setting parameter as '%locale%'.
http://symfony.com/doc/current/best_practices/i18n.html
A lot of information about IP and OS there are in $_SERVER.

asp.net mvc save user selection globally

I am developing a mvc 5 web application which allow user to select language and currency to be displayed to them, in which the choice of language and currency they selected is expected to be retrievable throughout the controller and view.
Do note that the user i referring here is anonymous user (which is user that do not log in) so i do not intend to save their selection to database.
I am thinking of using session to store the selection. However, it seems not a good choice of to me as these are only two values that i need to store in session. Is there any other better alternative?
An alternative is to put language in url
{language}/{controller}/{action}/{id}
e.g.
en/home/index
fr/home/index
Advantage is that the url is bookmarkable and clearer
An example implementation: http://adamyan.blogspot.sg/2010/07/addition-to-aspnet-mvc-localization.html
For currency, I'll probably determine it from the culture of user, or at least use that value as default for first time user. If you want to let user be able to change it, cookie is fine in my opinion.

Sharepoint - Weird language behavior after translation

I'm currently encountering a weird behavior of sharepoint in my current project.
The task is simple in its core:
We have a site collection, where we can create projects (projects are then subsites of the root site again). In v1 our product was only available in one language. In v2 we implement multilanguage.
When the new solutions are deployed, new project site are in the correct state.
The rootsite and older project sites are not.
I'm currently developing the update mechanism for the root and subsites.
And here somethin unexplainable (at least for me) happens:
Navigation:
The navigation nodes have to be updated the following way
foreach (CultureInfo culture in web.SupportedUICultures)
{
node.TitleResource.SetValueForUICulture(culture, SPUtility.GetLocalizedString("$Resources:" + key, resource, (uint)culture.LCID));
}
node.Update();
When I initiate the update while having german as my active display language, exactly 2 nodes are shown as $Resources:.... in german, but in english they are correct.
If i initiate the update while having english as my display language, all nodes are correct in both languages.
Listviewwebpart
On one page we introduced a few listviewwebparts. I create them and customize the view of the webpart. When I start the update with english as language, everything works fine.
The listview is completely translated both in german and english.
However, the moment i let the update run with german as active language, some fields are not translated. And here is the thing: Only in this exact listview! When i switch to the list, and check the fields, everything is ok!
I don't get it.
So in short:
- Update with german: 2 Navigation don't get the resource value (just german, english works fine)
- Update with english: Fields in listview not translated, but the fields are translated in its core.
Did someone ever encountered a behavior like this?
I tried changing the order in which the update works, but nothing changes.

User Session using different languages and MVVM

I am writing a desktop application using MVVM and Prism and I have the following problem. As well as the labels etc it is also necessary to store data in different languages.
For example, in the USA a user might be able to login using either English or Spanish (as they are a native speaker).
If the user logs in using Spanish when they go into a product details
form the product description will be saved to the database against
the Spanish language.
If they log in using English the product description will be saved to
the database and related to the English language.
At the moment my only ideas is as below:-
- a globally accessible ApplicationViewModel that contains a
CurrentLoggedInUser property
What I would like to know is how I go about saving the currently logged in user's chosen language when using MVVM, particularly in a desktop application?
N.B the chosen language can be different to the language and locale that the operating system is in
How do other people go about resolving this and maintaining the user's "session" across different windows / user controls when using MVVM?
All you need to do is store the current language somewhere, maybe as an LCID.
Generally this is used to load a language specific resource file, which takes care of most language dependant situations. Controls etc just store all their strings in resources, so they don't need direct access to the current language.
For situations where you do need access to the language, such as knowing where to save your database string, then yes, the language should be exposed either as some static/singleton, or more desirably, should be injected into whatever ViewModels need it.

Categories