Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yasinkuyu/localization
:fire: Create multi-language structure with ASP.NET MVC
https://github.com/yasinkuyu/localization
c-sharp i18n localization net-mvc
Last synced: 7 days ago
JSON representation
:fire: Create multi-language structure with ASP.NET MVC
- Host: GitHub
- URL: https://github.com/yasinkuyu/localization
- Owner: yasinkuyu
- License: mit
- Created: 2014-05-24T21:07:27.000Z (over 10 years ago)
- Default Branch: Haster
- Last Pushed: 2019-12-31T10:46:02.000Z (almost 5 years ago)
- Last Synced: 2024-04-30T01:02:00.738Z (7 months ago)
- Topics: c-sharp, i18n, localization, net-mvc
- Language: C#
- Homepage:
- Size: 58.6 KB
- Stars: 38
- Watchers: 4
- Forks: 19
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Localization
============Create `multi-language` structure with ASP.NET MVC [@yasinkuyu](https://twitter.com/yasinkuyu)
PM> Install-Package Localization
### Usage
-
-
and more...
Or
- English
- Türkçe
and more...
Index.cshtml
@Html.Get("homepage") or @Html.Localize("homepage")
### Video Tutorial
[![ASP.NET MVC Localization Tutorial vimeo](https://i.vimeocdn.com/video/476545847_295x166.jpg)](https://vimeo.com/96483908)
[![ASP.NET MVC Localization Tutorial youtube](https://i.vimeocdn.com/video/476545847_295x166.jpg)](http://youtu.be/9V5PS4m0er0)
Requirements
---------------
Localization
- en_US.xml
- tr_TR.xml
- and more...
Bin
- Insya.Localization.dll
- System.ComponentModel.DataAnnotations
Default locale
public void DefaultLocale( )
{
HttpCookie cookie = Request.Cookies.Get("CacheLang");
if ( cookie == null)
{
HttpCookie newCookie = new HttpCookie("CacheLang");
newCookie.Value = "en_US";
Response.Cookies.Add(newCookie);
}
}
Structure
---------------
### Views
Xml file
Home Page
Razor
@Html.Localize("homepage")
Or
@Html.Get("homepage")
Code Behind
Localization.Localize("homepage")
Or
Localization.Get("homepage")
@Html.ActionLinkLocalization()
@Html.ActionLocalization()
### Inline Localization
@Html.Get(new Inline(en: "book", tr: "kitap"))
@Html.Localize(new Inline(en: "book", tr: "kitap"))
### Controllers
```
public ActionResult Index(string lang = "en_US")
{
Response.Cookies["CacheLang"].Value = lang;
if (Request.UrlReferrer != null)
Response.Redirect(Request.UrlReferrer.ToString());
var message = Localization.Get("changedlng");
return Content(message);
}
```
### Models
Attribute Localize
Display Attribute
[DisplayLocalize("username")]
public string Username { get; set; }
String Length Attribute
[StringLengthLocalize(20, MinimumLength = 4)]
public string DisplayName { get; set; }
Required Attribute
[RequiredLocalized]
public string DisplayName { get; set; }
Description Attribute
[DescriptionLocalize]
public string DisplayName { get; set; }
----------
**Intellisense in razor files (Views/web.config)**
- Views
- web.config
- system.web.webPages.razor
- pages
- namespaces
- add namespace="Insya.Localization"
- add namespace="Insya.Localization.Helpers"
Example
```
##
##
```
**Note:** Nuget package auto insert
### Language Codes
https://msdn.microsoft.com/en-us/library/ms533052(v=vs.85).aspx
### Contribution
Fork
**Roadmap:**
- Localizable Routing
- All the XML language files editing tool on one screen.
- Testing tools