I have a question about localization
how can i do localization lets say that i have a dropdown list
that holds the available languages: English,french and arabic
and I have a label which get it says "good morning",so i want to change the lang. according to selected lang. in drop down list so when the user chooses french label will say "bonjour" and when the user slect arabic the label will hold "صباح الخير" AND MOVE IT FROM THE LEFT OF THE PAGE TO THE RIGHT BECAUSE ARABIC IS WRITTEN FROM RIGHT TO LEFT ,,
ANY HELP WILL BE HIGHLY APPERCAITED
THNX IN ADVACE
In short, localization in ASP.NET is fully supported using resource files, e.g. files containing strings, images and other resources for each user interface language. They're named after the culture, for example MyResources.en-US.resx or MyCulture.fr-FR.resx.
The only thing that is a bit tricky is handling LTR and RTL languages and, as far as I know, must be done "manually", via code, or via CSS.
You might want to check some documentation on MSDN.
Have you ever saw the Localization video tutorials from ASP.NET website?
How Do I: Create a Multi-Lingual Site with Localization?
and
How Do I: Localize an ASP.NET AJAX Application?
They are great to get you started...
you can create an http module that is going to read the html from the output stream and translate it,use RegEx and make sure not to translate html tags and JavaScript
there is also the asp.net standard (built-in) way, with resource files, just right click your project and click add items resource file, you must create a resource file for each language like for example: MUI.resx (that's the neutral one), MUI.fr.resx, MUI.es.resx, and you are going to use them in the web pages like this: MUI.keyword , that's if you are going to have one resx per language for all pages, you could also have one resx per language per webform.
And the current language is in the System.Threading.CurrentThread.CurrentUICulture
google it a little bit you will find more, at least now you know what to look for
Related
I need to develop a web site with a long long list of requirements.
One of those is allowing the site admin to add new languages to the site (that's something easy I would say, resources and voila), but with that language I need to "culturalize" the site, this is, changing the currency, changing the date format, changing the decimal separator (comma in Argentina, dots in US), and stuff like that.
So, my question is: Are there any easy way to do this job? What can you recommend me to do it?
If the solution is using resource files, and you have any example, that'd be great.
I'm trying to avoid jQuery because the tool that does the required thing is more like a plugin rather than a "script", and also isn't very trustworth or reliable, I think.
Take a look at ASP.NET Infrastructure for ASP.NET MVC3, the Globalization video. This is a great video that goes over the basics of everything you will need.
Thread.CurrentCulture gets or sets the current culture.
Thread.CurrentUICulture handles resources for each language.
There is also a <globalization> section in the Web.Config.
Hopefully this will get you on the rite track.
I developed a (small) company website in Visual Studio, and I'm addicted to learning more. I really just have two simple questions that I can't google.
1 - Asp:hyperlinks:
What is the purpose of an asp.hyperlink? I know I can't use these in my resource files -- I have to convert 'em all back to html links. At first, asp:hyperlinks looked sophisticated, so I made all my links asp:hyperlinks. Now I'm reverting back. What's the purpose of an asp:hyperlink, if any?
2 - Resource Files and strings:
In localizing my website, I have found that I'm putting the .master resource files in the directory's App_LocalResources folder VS created, because you can't change the top line stuff in a .master file and put a culture/uiculture in there. But all of my regular .aspx pages are going into the root App_GlobalResources folder into 1 of 4 language resource files (de, es-mx, fr, en). I'm making 2 or 3 strings per .aspx page. So when you have 47 pages in your website, that's about 100 strings on a resource page.
I just learned about all of the resources stuff from this forum and MSDN tutorials, so I have to ask, 'cause it's a lot of work. Is this okay? Is it normal? Am I going about this the wrong way?
I've never used resources, so can't comment on that.
Differences between asp:hyperlink and a tag that I know of:
asp:hyperlink is converted to an A tag by the ASP.NET engine when output to the browser.
It is possible asp:hyperlink could make browser specific adjustments, to overcome browser bugs/etc.. which is kind of the point of ASP.NET, or at least one of them. If not already in it, they could be added later, and by using those objects you'll get that when/if added.
Both can be used in code behind (you can set runat="server" for an A tag), but the asp:hyperlink has better compile-time checking in most cases -- strong type-casting for more items vs generic objects.
asp:hyperlinks are easier to get HTML bloat, but only if used with a poor design. For example, it is easy to set font styles and colors on them.. but I wouldn't, since that generates in-line styles that are usually pretty bloated compared to what you would do by hand or in a CSS file.
asp:hyperlinks support the "~/Folder/File.ext" syntax for the TargetUrl (href), which is nice in some projects if you use a lot of different URLs and sub-folders and want the server to handle mapping in a "smart" way.
The purpose of is to display a link to another webpage.
With the resource files, since you're not a programmer and just developing a small program, use something you're comfortable with. Resource files are easy to use for beginners when you want to localize your web content -- and yes, it's normal to be adding many strings if you need them.
For #1
Using a hyperlink control over just a piece of text will allow you to access the control at runtime and manipulate its contents if you want to change the link dynamically, if you have static links that will never change then its simpler to just use plain text ie. <a href=''>
I'm creating a website template where the owner of the site will be able to choose a native language other than English and localize some content by themselves. Let me explain it better with the real situation right now: My site will have English and Turkish (my native language is Turkish, but THIS should be changeable and applied to any non-English language) versions of the main content titles, such as BLOG, PROJECTS, ABOUT, CONTACT etc, but number and name of these are completely dependent to the choice of the user, so I could open a new section named MySection, and it's title and it's native translation to Turkish will be stored in my DB (using EF). Also in my settings at the DB, the native language's code (in this case "tr") is stored. What is the most modular/organized way of sending the webpage content according to browser, just like this:
In DB, sections are organized this way (titles and their Turkish translations) (all these will be at arbitrary number and completely user created):
Title NativeTitle
---------------------
BLOG BLOG
PROJECTS PROJELER
ABOUT HAKKINDA
Also I have my native language setting (that I've created) setting as tr (which is up to the site owner and can be changed too). So, depending on the user's browsers preferred language setting, I want to show the Turkish content, and for all the other language preferences, including (obviously) English, I want to show the default English content. Localization for a specific language of static content is pretty straightforward with RESX files, but in my situation, I neither have static content nor a specific known native language, so all my data comes from the DB. I want to code this as less as possible and as declarative as possible. What is the best practice of doing this? Is checking the setting of the native language and the Current Culture in a page and if they are equal sending the native else sending the default title the only way? It WILL definitely work, but what if I want to extend it to other parts of the site? I don't want if's and else's everywhere around the site, I need some kind of a centralized string mapping system. What's the best way?
You can override the InitializeCulture ( http://msdn.microsoft.com/en-us/library/system.web.ui.page.initializeculture.aspx ) method in your base Page to dynamically load your localized content by checking the Thread.CurrentThread.CurrentUICulture property ( http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.currentuiculture.aspx )
I am working on a multilingual web application. I'm wondering how do i design the best user interface that the user can localize data for various languages? for instance, in making a page which its title is different in every lang, do i put a textbox for every one? it's not a suitable way to do(in case of 10 lang, the user has 10 textbox!!! too silly)
what is your idea about this?
Edit: i have no problem with globalization in my system. in fact, i'm looking for a good way for my interface design which user can enter his data to my forms in various langs.
thanks in advance
What about only one textfield and a dropdown containing the languages. After selecting the language and filling out the textfield the field gets submitted and the chosen language disappears from the dropdown list.
the entered value and language then appears beneath the dropdown and textbox with a way to edit/delete it. this way it's always clear to the user which languages are already covered and which values are assigned to them. furthermore it's a nicer way if not all 10 languages have to be mandatorily filled in, if the user e.g. just knows english and french.
Hope you know what I mean, otherwise I'll have to create an example screenshot :-)
You could have 3 text boxes, and that's fine...get to 10, and it starts getting a bit crazy. Beyond that it starts looking pretty bad.
Maybe you could put up to say 5 text boxes up...but if it goes beyond 5 (because the user desires localization for more than 5 places) it places a single textbox with a dropdown next to it, and the dropdown would contain the current language.
Textbox would auto-populate with the current value for the language selected in the dropdown. Should work well in asp.net, and it can be done both client side, or server side on a post back pretty easily, so you don't need to do anything crazy for people not running javascript.
You have one text box.
On load you populate the text box depending on language.
The content will be populated from some kind of resource file. If there isn't much text it could even go in your config file.
Be aware of the following:
Different content length depending on language.
Right to Left alphabets screwing up your alignment
This is a classic project for using NUNIT or similar to promve that things work after new translations are added!
What language do you use in development? If this is something like PHP, then you definitely should use templates and load text strings into them from configuration files for every language. In Smarty, for example, I use configuration files for that.
Text strings for error messages or something like that could be put to files like .ini and loaded from there.
The Google Web Toolkit (GWT) demo shows the same page with versions available in English, French, Arabic and Chinese.
The GWT docs have a thorough discussion of internationalization. You could emulate their implementation.
Constants: Useful for localizing typed constant values
Messages: Useful for localizing messages requiring arguments
ConstantsWithLookup: Like Constants but with extra lookup flexibility for highly data-driven applications
Dictionary: Useful when adding a GWT module to existing localized web pages
Remember that dates and times are represented differently in different locales, if your forms use them.
The W3C also discusses Internationalization Best Practices in HTML content.
Normally, a user navigating a website will have a preference specifying the language of the whole site. I think it would be confusing to break this pattern.
So, in an intro page, or a user preferences page, allow the user to select a language; then, on the other pages, display a consistent set of controls to be able to edit the content on each page.
Are you making an administration page that allows users to change the text used in other pages in the application?
If so, you could use grid like in Zeta Resource Editor:
thumbnail http://img202.imageshack.us/img202/7813/zetaresourceeditor02.th.png
Or you could make a per-language list like in nopCommerce:
thumbnail http://img249.imageshack.us/img249/9079/nopcommerce.th.png
You can use javascipts as a resource file for your language like. language_arabic.js, language_english.js,etc.So when a use wants to see his preference language he/she has select the available languages from drop down list. Regarding this the user has to change the language settings from his/her computer. This is what I did while I was working a GIS project to customize a Geocortex IMF( http://demos.geocortex.net/imf-5.2.2/sites/demo_geocortex/jsp/launch.jsp ) site for an Arabic client.
How do you guys handle translation/internationalization of your ASP.NET applications? How do you work with your translators?
We have ASP.NET apps that need to be available in German, French, Italian, English. We use string resources everywhere. However, more than once, our translators have told us just getting a bunch of "txtMyTextbox.Text" and then a German text to be translated is next to impossible to deal with - the context is missing.
So are there any other solutions available? Due to the fact these translators are dispersed all over Europe, we cannot get them to fly in and do their work "on location" - there has to be a way to send them the text fragments to be translated, along with some context, and let them do their work.
Is there any tool out there that would allow me to package up my ASPX pages and ASCX controls along with the text resources, and that would actually visualize them to the translator (without him having to install and host IIS and all) ? I vaguely remember there was a lot one tool in my olden Delphi days that did that - visualize the form (without the real app running), and allowing someone to pick the labels and translate them.
Or would there be a tool that would allow me to make screenshots of my ASPX pages and highlight all label and display their control name ("txtMytextbox") in red, so that the screenshot could serve as an orientation help for someone working on translating a list of labels?
Any hints are most welcome and highly appreciated!
Marc
take a look at the Lingobit http://www.lingobit.com/
How about going around ASP.NET's insternationalization scheme and using a diferent approach, using .po files like the "rest of the world" . The actual text is the key, and translators see that text qhen they are translating. Works pretty well.
http://www.expatsoftware.com/articles/2010/03/fixing-internationalization-in-aspnet.html
describes this.
Make your resource keys more meaningful. This will give them some context
Can the translators get access to a running app? If so, you could set the tooltips of all your labels to be the resource key. That would allow them to mouse over a label to see where its string is coming from.
As your translators become more familiar with the product, they'll be able to better cope with the lack of context. The first time around is a little rough, and you'll need to go through a few rounds of testing and translation revisions. There's not much you can do about it.
Here is the article written by Scott Hanselman. Hope it helps
Globalization, Internationalization and Localization in ASP.NET