Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
What are the best practices for language(localization) in Umbraco? We have tried to add dropdown option with language code on it and added a page with postfix on their name example (Default-NL, Default-US).
Can you give me some pointers to be read of any recommendations?
Thanks in advance.
Use the dictionary : Add languages to the Umbraco settings, and translate text to be localized in the dictionary.
Manage hostnames : By assigning the appropriate language to the rootnode(s), the culture will be set to this language by Umbraco, and the corresponding date settings, dictionary items, etc. will be used.
For multi-language sites, you'll probably want to have a document tree for each language and set the hostname/language settings appropriately. Of course you should be able to use the same templates for every language (use the dictionary, no static text in the templates). A common workflow is to set up the web site in you main language, then copy the entire document tree and translate it.
I have recently developed a multi-territory, multi-language site and I handled the content tree much as Marapet has described. Each language defined as a separate branch under the root node.
You can define a "umbracoUrlName" property of the DocumentType for a language homepage which will allow you to specify a 2-character code for the URL path whilst retaining a more descriptive title for the page.
With regards to the localization, I personally use Umbraco's dictionary feature for setting internal translations, e.g. DocumentType names, Property names and Descriptions. This is so that CMS user's can use Umbraco in different languages.
The limitation of the Dictionary is that all values are held in a database so it does not function like .Net resource files. For example, if no translation exists for a specific language for a key in the dictionary, an empty string will be served. Ideally, you would want the kind of fallback value that .Net resource files offer. For this reason, I implement a custom section for maintaining resource files and values for use in the published sites.
I can define a Invariant resource with default values which each language site can fall back to if no overriding language has been defined.
The other advantage of this is that I can ensure that CMS authors do not need access to the Settings section of the CMS.
Related
I'm using a custom route in my ASP.NET MVC app (/lang/{culture}/{controller}/{action}/{id}) and in my base controller, I'm detecting the presence of a value for the culture parameter and setting the current thread culture. However, if someone manages to navigate to a language that doesn't have any resources, rather than silently falling back to the default culture, I want to present a message indicating the lack of language support.
How can I detect if the current culture has no resources specified rather than silently falling back to the default?
The issue is that in practice it's complicated to programmatically determine whether you have localizations for a given culture. You may have satellite assemblies for a given culture for one assembly, but not for another. And worse, one satellite assembly may contain translations for some resources, but not all. This may be intentional: for en-GB you may prefer to only take an "override rather than duplicate" approach and define only a few resources here and there, only where you differ from your base English.
So the simplest and clearest approach may be to maintain a hard-coded master list of supported cultures in your application code, and then just base your language support alerting logic on this list. When you add a new localization, you'll need update that list in code. But most of us do localization by checking-in new resource files into the solution anyway--there already isn't a complete separation between code and localized resources.
There doesn't seem to be a direct API to give you the list of available cultures from the resource files.
One possible solution is to enumerate the resource files and parse out the language code.
Take a look at this SO question: Get available languages from resource
Learning asp.net mvc and I am building a small website that will be initially in 2 languages.
10 or more pages are static pages with bold bits etc...
What is the best approach for localising these pages?
Is there a way to do it without creating a page for language that would be a no in my book.
How do you handle localisation of static pages in asp.net mvc? In asp.net there was some sort of localise control.
Any suggestions?
The way to do this is using resource files. You create an resource file for your default language and then one for each other language your site should run in.
This article describes how to do it. For example if you want english (default) and french you could create two resource files (.resx files) Website.resx and Website.fr-FR.resx. The first file for your default language, which is english and the second file for french. Both files exists from a key-value pair.
EDIT: Another interresting article describing the same idea can be found here.
I think that the best approach is still creating two files for them,
cause they are not static pages forever, they may change in future,
Or you can generalize the solution and save the text in database
for those two languages and render the correct content base on the selected culture.
They can be saved in the sense that they are pages on newsroom,
whenever you add a news you enter the text for both cultures.
We're currently debating two strategies of localization:
A. Have an XML file for the structure of the business objects with a Localized key to a separate CSV file for the translation.
for eg. /Resources/Schema.xml
in a separate CSV file: we have all key/value pairs for the translations:
/Resources/Localized.txt
Model_Title, Title, Title (in French), ...
This way, when the structure changes, we just change XML once while the LocalizedKey's are in place.
B. Have separate XML files for each language based on Culture.
eg. have two files:
/Resources/en-US/US-Localized.xml
/Resources/fr-AU/AU-Localized.xml
This way, they will have same schema but separate files. Therefore the user would have to make sure that the schemas are the same as they would need to change it twice as opposed to Option #1 where they can just change it once.
However, the readability here is much better since the user would not have to track the key the make the changes.
What are your thoughts/ideas on the strategies I suggested?
Thanks,
It is not clear about the environment -- web? desktop? internal enterprise integrated something-or-other? Is there any particular reason you aren't using whatever i18n framework your tool chain supports (gettext, .NET resource files...)?
In general I'd say you want to separate out resources by culture (but to be honsest, fr_AU should be rare) to have better maintainability and do not have to load the entire file for all per-culture-versions in many situations. This is especially true if your number of supported languages/cultures goes into the dozens or more.
However, it would be important to accommodate XML schema changes. The XML could be auto-generated, from simpler structures (key-value, either in a database or files) and validated via a common schema.
This is whether (as commenters noted) you are providing localized products or customers can create their own localizations.
In general, you should consider existing tools, rather than start from the scratch.
In .net we are using Data Driven ASP.NET Localization
Resource Provider and Editor Created by rick strahl
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Does anyone know of a good/usable ASP.NET MVC code/solution generator. Ideally it would build from a domain model, but from a data model is also acceptable.
If you do, can you answer the following:
Does it produce "good" code?
Can it be extended?
What do you like and not like about it if you have used it?
What great fearures does it come with that stand out?
If there isn't one you know of then do you think this is something missing from the community or do you not think it is needed? What features would you like to see in one?
Can't wait to hear your answers...
Thanks
Scott
S#arp Architecture includes scaffolding generator using T4. It generates model, views, controllers, and tests from the template model definition. You get full CRUD. Since it uses T4 (Visual Studio template language I suppose) you can extend default templates as you want.
Here's an example of the template:
EntityScaffoldingDetails entityScaffoldingDetails =
new EntityScaffoldingDetails("Organization.Worker");
/*
* Property names should be PascalCase.
* Do not include a property for Id as it will be included automatically.
*/
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("FirstName", "string", "Joe", "[NotNull, NotEmpty]", true)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("LastName", "string", "Smith", "[NotNull, NotEmpty]", true)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("BirthDate", "DateTime", DateTime.Parse("1/1/1975"))
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("Manager", "Employee", null, "[NotNull]")
);
///////////////////////////////////////////////////
// The first parameter should reflect the root directory of your solution
//ScaffoldingGenerator generator = new ScaffoldingGenerator(
//#"D:\Work\Project\", "Orders", entityScaffoldingDetails);
// Uncomment this line when you're ready for the scaffolding generator to fire...be sure to recomment after it completes to avoid accidental generating!
//generator.Run();
One small addition: I would not recommend using it as is, because, for example, I'd prefer controllers to work with ViewModel, not entities. And I don't use scaffolding much. But it is pretty flexible, though you may need to learn T4.
You could try a Visual Studio 2010 extension called Radarc. It has a repository of extensions (called Formulas) which allows you to generate solutions for different architectures and technologies. Using Radarc with MVC Formula you can create ASP.Net MVC 3 applications with EF Code First either from a new domain model or importing an existing database.
I am working in this product team so I am not too objective to reply all your questions, but yes it can be extended.
Have you taken a look at Naked Objects MVC ? at least for academic reasons is very interesting.
The Naked Objects MVC framework will take a Domain model (written as POCOs) and render it as a complete HTML application without the need for writing any user interface code - by means of a small set of generic View and Controller classes. The framework uses reflection rather than code generation.
The developer may then choose to create customised Views and/or Controllers, using standard ASP.NET MVC patterns, for use where the generic user interface is not suitable.
Try www.datatreepages.com.
You connect the designer at your database and it generates data entry pages with sorting/searching/paging. You can also design layouts which allow you to link data pages together on the screen for master/detail relationships.
The controllers, data access, models, view models, csthml, javascript/jquery, html/css are all written for you. The code produced is simple and extendable.
I'm about to take a look at how to implement internationalisation for an ASP.NET MVC project. I'm looking at how to allow the user to change languages. My initial though is a dropdownlist containing each of the supported langauages. Whoever a few questions have come to mind:
How to store the list of supported languages? (e.g. just "en", "English"; "fr", "French" etc.) An xml file? .config files?
If I store this in a file I'll have to cache this (at startup I guess). So, what would be best, load the xml data into a list (somehow) and store this list in the System.Web.Cache? Application State?
How then to load this data into the view (for display in a dropdown)? Give the view direct access to the cache?
Just want to make sure I'm going in the right direction here...
Thank you.
First tell us please what you understand under "internationalization"?
a) You want to only have UI in several languages
b) You want to have the content in several languages
Have a look at this other question where I did some explanation on the topic: Advice on ASP.NET Multi-Lingual Strategy
To your questions:
I would advice storing a list of supported languages in DB where you can identify them by 2-character code. See ISO 3166-1 alpha-2 country codes.
If you're coming from the ASP.NET WebForms world, then the first thing to unlearn would be the statefulness and cache when you're dealing with ASP.NET MVC. You can store a simple single value in session or cookies that will indicate the currently active languages. The server side will generate a view in the required language based on this submitted values.
You instantiate a model in your controller to be passed to the view. In the model you can have a property - a list with available languages. The view can (and supposed to) consume the data to display from its model.
Regarding where you could store a cached version of languages. You can consider having somewhere a static list that will be initialized at the first request (like weak references). It will be shared then across all requests for a given application domain, meaning all the users of your web app will see the same values (until the domain gets recycled or the server restarted). If you were to use the server session, then the list would be created again for each new user session.