Skip to content

Commit

Permalink
Nuget package 1.0.7 update
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinkuyu committed May 26, 2014
1 parent 4bc68a9 commit edc7d6e
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 18 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ Localization

Create `multi-language` structure with ASP.NET MVC

PM> Install-Package Localization
PM> Install-Package Localization


### Usage

* <li>@Html.ActionLinkLocalization("English", "Index", "Locales", new { lang = "en_US" })</li>
* <li>@Html.ActionLinkLocalization("Türkçe", "Index", "Locales", new { lang = "tr_TR" })</li>
Or
* <a href="Locales/?lang=en_US">English</a>
* <a href="Locales/?lang=tr_TR">Türkçe</a>
- <li>@Html.ActionLinkLocalization("English", "Index", "Locales", new { lang = "en_US" })</li>
- <li>@Html.ActionLinkLocalization("Türkçe", "Index", "Locales", new { lang = "tr_TR" })</li>
Or
- <a href="Locales/?lang=en_US">English</a>
- <a href="Locales/?lang=tr_TR">Türkçe</a>

Index.cshtml

* @Html.Get("homepage") or @Html.Localize("homepage")
@Html.Get("homepage") or @Html.Localize("homepage")



Expand All @@ -42,12 +42,12 @@ Structure
---------------

### Views
Xml file
Xml file
<item id="homepage">Home Page</item>

Razor
@Html.Localize("homepage")
Or
Or
@Html.Get("homepage")
Code Behind
Expand Down Expand Up @@ -98,11 +98,12 @@ public ActionResult Index(string lang = "en_US")

**Intellisense in razor files (Views/web.config)**
- Views
- web.config
- system.web.webPages.razor
- pages
- namespaces
- add namespace="Insya.Localization"
- web.config
- system.web.webPages.razor
- pages
- namespaces
- add namespace="Insya.Localization"
- add namespace="Insya.Localization.Helpers"


Example
Expand All @@ -118,12 +119,13 @@ Example
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
## <add namespace="Insya.Localization" />
## <add namespace="Insya.Localization.Helpers" />
</namespaces>
</pages>
</system.web.webPages.razor>
```

**Note:** Nuget package auto insert <add namespace="Insya.Localization" />
**Note:** Nuget package auto insert <add namespace="Insya.Localization" /> <add namespace="Insya.Localization.Helpers" />



Expand Down
12 changes: 12 additions & 0 deletions src/Helpers/LocalizeHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ public static MvcHtmlString Localize(this HtmlHelper helper, string id)
return new MvcHtmlString(Localization.Localize(id));
}

/// <summary>
/// Razor template using @Html.Localize("id")
/// </summary>
/// <param id="helper"></param>
/// <param id="id"></param>
/// <param id="lang"></param>
/// <returns></returns>
public static MvcHtmlString Localize(this HtmlHelper helper, LangCode lang)
{
return new MvcHtmlString(Localization.Localize(lang));
}

/// <summary>
/// or Razor template using @Html.Loc("id")
/// </summary>
Expand Down
22 changes: 22 additions & 0 deletions src/ILangCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @yasinkuyu
// 05/08/2014

namespace Insya.Localization
{
interface ILangCode
{
string de_DE { get; set; }
string en_CA { get; set; }
string en_US { get; set; }
string en_GB { get; set; }
string es_ES { get; set; }
string es_MX { get; set; }
string fr_FR { get; set; }
string it_IT { get; set; }
string ja_JP { get; set; }
string pt_BR { get; set; }
string ru_RU { get; set; }
string tr_TR { get; set; }
string zh_CN { get; set; }
}
}
110 changes: 110 additions & 0 deletions src/LangCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// @yasinkuyu
// 05/08/2014

namespace Insya.Localization
{
public class LangCode : ILangCode
{

/// <summary>
/// English(United States)
/// </summary>
/// <returns></returns>
public string en_US { get; set; }

/// <summary>
/// Turkish (Turkey)
/// </summary>
/// <returns></returns>
public string tr_TR { get; set; }

/// <summary>
/// Chinese (simplified, PRC)
/// </summary>
/// <returns></returns>
public string zh_CN { get; set; }

/// <summary>
/// Russian(Russia)
/// </summary>
/// <returns></returns>
public string ru_RU { get; set; }

/// <summary>
/// French(France)
/// </summary>
/// <returns></returns>
public string fr_FR { get; set; }

/// <summary>
/// Spanish(Spain)
/// </summary>
/// <returns></returns>
public string es_ES { get; set; }

/// <summary>
/// English(United Kingdom)
/// </summary>
/// <returns></returns>
public string en_GB { get; set; }

/// <summary>
/// German(Germany)
/// </summary>
/// <returns></returns>
public string de_DE { get; set; }

/// <summary>
/// Portuguese(Brazil)
/// </summary>
/// <returns></returns>
public string pt_BR { get; set; }

/// <summary>
/// English(Canada)
/// </summary>
/// <returns></returns>
public string en_CA { get; set; }

/// <summary>
/// Spanish (Mexico)
/// </summary>
/// <returns></returns>
public string es_MX { get; set; }

/// <summary>
/// Italian (Italy)
/// </summary>
/// <returns></returns>
public string it_IT { get; set; }

/// <summary>
/// Japanese(Japan)
/// </summary>
/// <returns></returns>
public string ja_JP { get; set; }

public LangCode(string en = "", string tr = "", string es = "", string de = "", string fr = "", string it = "", string enCA = "", string enGB = "", string esMX = "", string jaJP = "", string ptBR = "", string ruRU = "", string zhCN = "")
{
en_US = en;
tr_TR = tr;
de_DE = de;
es_ES = es;
fr_FR = fr;
it_IT = it;
en_CA = enCA;
en_GB = enGB;
es_MX = esMX;
ja_JP = jaJP;
pt_BR = ptBR;
ru_RU = ruRU;
zh_CN = zhCN;
}

public LangCode()
{
}

}

}
13 changes: 13 additions & 0 deletions src/Localization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ public static string Localize(string id)

}


/// <summary>
/// Todo: Inline localization
/// </summary>
/// <param name="id"></param>
/// <returns>xml item id</returns>
public static string Localize(LangCode lang)
{
return _loc.GetLang(lang.en_US.ToString());

}


// ToDo this
public static string Set(string id)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Localization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<ItemGroup>
<Compile Include="Attributes\DescriptionLocalizeAttribute.cs" />
<Compile Include="Attributes\DisplayLocalizeAttribute.cs" />
<Compile Include="ILangCode.cs" />
<Compile Include="LangCode.cs" />
<Compile Include="Resource.cs" />
<Compile Include="Helpers\ActionLinkLocalization.cs" />
<Compile Include="Helpers\ActionLocalization.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("www.insya.com")]
[assembly: AssemblyProduct("Insya")]
[assembly: AssemblyCopyright("Copyright © 2014 Insya Interaktif")]
[assembly: AssemblyCopyright("Copyright © 2014 Insya Interaktif")]
[assembly: AssemblyTrademark("Insya Interaktif")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.7.0")]
[assembly: AssemblyFileVersion("1.0.7.0")]

0 comments on commit edc7d6e

Please sign in to comment.