Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'DC-Package2' of https://github.com/DavidChristiansen/in…
…ternationalization-mvc4 into DavidChristiansen-DC-Package2
- Loading branch information
Showing
27 changed files
with
317 additions
and
1,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,43 @@ | ||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<!-- Values in dollar $igns are automatically pulled from the AssemblyInfo.cs attributes by NuGet.exe --> | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> | ||
<metadata> | ||
<id>Code52.i18n.MVC3</id> | ||
<version>0.1</version> | ||
<title>[Code52] i18n Core for MVC3</title> | ||
<authors>bforster, dchristiansen</authors> | ||
<owners>bforster, dchristiansen</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<iconUrl>http://code52.org/internationalization-mvc4</iconUrl> | ||
<description>A core package to create an internationalization-ready web application</description> | ||
<summary></summary> | ||
<tags>localization globalization MVC MVC3 ASP.NET Web</tags> | ||
<authors>bforster,dchristiansen</authors> | ||
<owners>bforster,dchristiansen</owners> | ||
<projectUrl>http://code52.org/internationalization-mvc4</projectUrl> | ||
<iconUrl>https://github.com/DavidChristiansen/internationalization-mvc4/raw/master/docs/logo/ProjectIcon.png</iconUrl> | ||
<dependencies> | ||
<dependency id="AntiXSS" version="4.2.1" /> | ||
<dependency id="Code52.i18n" /> | ||
<dependency id="jquery-globalize" version="[0.1.0]" /> | ||
<dependency id="ModelMetadataExtensionsWithBugfix" version="0.1.2" /> | ||
<dependency id="WebActivator" version="1.5" /> | ||
</dependencies> | ||
<id>Code52.i18n.MVC3</id> | ||
<title>ASP.NET Internationalisation (i18n) package for MVC3</title> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>A core package to create an internationalization-ready web application</description> | ||
<summary /> | ||
<releaseNotes>Initial release</releaseNotes> | ||
<tags>localization globalization MVC MVC3 ASP.NET Web i18n l10n</tags> | ||
</metadata> | ||
<files> | ||
<file src="Content\App_Readme\Code52.i18n.MVC.readme.txt" target="Content\App_Readme\Code52.i18n.MVC.readme.txt" /> | ||
<file src="Content\App_Start\AppStart_Code52_i18n.cs.pp" target="Content\App_Start\AppStart_Code52_i18n.cs.pp" /> | ||
<file src="..\..\Code52.i18n\NuSpec\Content\Code52.i18n\CultureHelper.cs.pp" target="Content\Code52.i18n\CultureHelper.cs.pp" /> | ||
<file src="Content\Code52.i18n\LanguageFilterAttribute.cs.pp" target="Content\Code52.i18n\LanguageFilterAttribute.cs.pp" /> | ||
<file src="Content\Code52.i18n\LocalizationHelpers.cs.pp" target="Content\Code52.i18n\LocalizationHelpers.cs.pp" /> | ||
<file src="Content\Content\code52.i18n\images\flags\de.png" target="Content\Content\code52.i18n\images\flags\de.png" /> | ||
<file src="Content\Content\code52.i18n\images\flags\es.png" target="Content\Content\code52.i18n\images\flags\es.png" /> | ||
<file src="Content\Content\code52.i18n\images\flags\fr.png" target="Content\Content\code52.i18n\images\flags\fr.png" /> | ||
<file src="Content\Content\code52.i18n\images\flags\gb.png" target="Content\Content\code52.i18n\images\flags\gb.png" /> | ||
<file src="Content\Content\code52.i18n\images\flags\it.png" target="Content\Content\code52.i18n\images\flags\it.png" /> | ||
<file src="Content\Content\code52.i18n\images\bg_regions_international_tile.png" target="Content\Content\code52.i18n\images\bg_regions_international_tile.png" /> | ||
<file src="Content\Content\code52.i18n\images\icon_international_map.png" target="Content\Content\code52.i18n\images\icon_international_map.png" /> | ||
<file src="Content\Content\code52.i18n\images\WorldHeader.png" target="Content\Content\code52.i18n\images\WorldHeader.png" /> | ||
<file src="Content\Content\code52.i18n\Code52.i18n.css" target="Content\Content\code52.i18n\Code52.i18n.css" /> | ||
<file src="Content\Controllers\LanguageController.cs.pp" target="Content\Controllers\LanguageController.cs.pp" /> | ||
<file src="..\..\Code52.i18n\NuSpec\Content\Scripts\Code52.i18n.js" target="Content\Scripts\Code52.i18n.js" /> | ||
<file src="..\..\Code52.i18n\NuSpec\Content\web.config.transform" target="Content\web.config.transform" /> | ||
<file src="tools\install.ps1" target="tools\install.ps1" /> | ||
</files> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,43 @@ | ||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<!-- Values in dollar $igns are automatically pulled from the AssemblyInfo.cs attributes by NuGet.exe --> | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> | ||
<metadata> | ||
<id>Code52.i18n.MVC4</id> | ||
<version>0.1</version> | ||
<title>[Code52] i18n Core for MVC4</title> | ||
<authors>bforster, dchristiansen</authors> | ||
<owners>bforster, dchristiansen</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<iconUrl>http://code52.org/internationalization-mvc4</iconUrl> | ||
<description>A core package to create an internationalization-ready web application</description> | ||
<summary></summary> | ||
<tags>localization globalization MVC MVC4 ASP.NET Web</tags> | ||
<authors>bforster,dchristiansen</authors> | ||
<owners>bforster,dchristiansen</owners> | ||
<projectUrl>http://code52.org/internationalization-mvc4</projectUrl> | ||
<iconUrl>https://github.com/DavidChristiansen/internationalization-mvc4/raw/master/docs/logo/ProjectIcon.png</iconUrl> | ||
<dependencies> | ||
<dependency id="AntiXSS" version="4.2.1" /> | ||
<dependency id="Code52.i18n" /> | ||
<dependency id="jquery-globalize" version="[0.1.0]" /> | ||
<dependency id="ModelMetadataExtensionsWithBugfix" version="0.1.2" /> | ||
<dependency id="WebActivator" version="1.5" /> | ||
</dependencies> | ||
<id>Code52.i18n.MVC4</id> | ||
<title>ASP.NET Internationalisation (i18n) package for MVC4</title> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>A core package to create an internationalization-ready web application</description> | ||
<summary /> | ||
<releaseNotes>Initial release</releaseNotes> | ||
<tags>localization globalization MVC MVC4 ASP.NET Web i18n l10n</tags> | ||
</metadata> | ||
<files> | ||
<file src="Content\App_Readme\Code52.i18n.MVC.readme.txt" target="Content\App_Readme\Code52.i18n.MVC.readme.txt" /> | ||
<file src="Content\App_Start\AppStart_Code52_i18n.cs.pp" target="Content\App_Start\AppStart_Code52_i18n.cs.pp" /> | ||
<file src="..\..\Code52.i18n\NuSpec\Content\Code52.i18n\CultureHelper.cs.pp" target="Content\Code52.i18n\CultureHelper.cs.pp" /> | ||
<file src="Content\Code52.i18n\LanguageFilterAttribute.cs.pp" target="Content\Code52.i18n\LanguageFilterAttribute.cs.pp" /> | ||
<file src="Content\Code52.i18n\LocalizationHelpers.cs.pp" target="Content\Code52.i18n\LocalizationHelpers.cs.pp" /> | ||
<file src="Content\Content\code52.i18n\images\flags\de.png" target="Content\Content\code52.i18n\images\flags\de.png" /> | ||
<file src="Content\Content\code52.i18n\images\flags\es.png" target="Content\Content\code52.i18n\images\flags\es.png" /> | ||
<file src="Content\Content\code52.i18n\images\flags\fr.png" target="Content\Content\code52.i18n\images\flags\fr.png" /> | ||
<file src="Content\Content\code52.i18n\images\flags\gb.png" target="Content\Content\code52.i18n\images\flags\gb.png" /> | ||
<file src="Content\Content\code52.i18n\images\flags\it.png" target="Content\Content\code52.i18n\images\flags\it.png" /> | ||
<file src="Content\Content\code52.i18n\images\bg_regions_international_tile.png" target="Content\Content\code52.i18n\images\bg_regions_international_tile.png" /> | ||
<file src="Content\Content\code52.i18n\images\icon_international_map.png" target="Content\Content\code52.i18n\images\icon_international_map.png" /> | ||
<file src="Content\Content\code52.i18n\images\WorldHeader.png" target="Content\Content\code52.i18n\images\WorldHeader.png" /> | ||
<file src="Content\Content\code52.i18n\Code52.i18n.css" target="Content\Content\code52.i18n\Code52.i18n.css" /> | ||
<file src="Content\Controllers\LanguageController.cs.pp" target="Content\Controllers\LanguageController.cs.pp" /> | ||
<file src="..\..\Code52.i18n\NuSpec\Content\Scripts\Code52.i18n.js" target="Content\Scripts\Code52.i18n.js" /> | ||
<file src="..\..\Code52.i18n\NuSpec\Content\web.config.transform" target="Content\web.config.transform" /> | ||
<file src="tools\install.ps1" target="tools\install.ps1" /> | ||
</files> | ||
</package> |
78 changes: 59 additions & 19 deletions
78
src/Code52.i18n.MVC/NuSpec/Content/App_Readme/Code52.i18n.MVC.readme.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,73 @@ | ||
[Code52.i18n] | ||
|
||
--Getting Started-- | ||
-- About Code52 i18n -- | ||
The purpose of the Code52 i18n project is to provide an easy way to implement localisation support to ASP.NET project. We currently have a reference implementation for MVC3 Razor and MVC4 Razor. | ||
|
||
We don't want to overwrite your default layout - in fact, it requires us to jump through some hoops and we're afraid we might annoy you. | ||
-- About Code52 -- | ||
We want to build fun stuff in our spare time, give back to projects which need support, and create a community which is inclusive and engaging. | ||
|
||
If you could kindly change your Views/_Layout.cshtml file to look like this: | ||
Find out more about Code52 on their website http://code52.org/ | ||
|
||
@{ | ||
Layout = "~/Views/Shared/_Layout.Code52.cshtml"; | ||
} | ||
-- Getting Started -- | ||
|
||
that'd be awesome. | ||
::::::::::::::::::::::::::::::: | ||
1. Create your Language resource file | ||
::::::::::::::::::::::::::::::: | ||
|
||
--Customizing-- | ||
Add a new item > Resources File. (If resources file isn't visible try changing the selection on the left hand side to the root (such as Visual C#) | ||
I usually create a resource file specifically for language resources | ||
|
||
If you want to update your master page (say if you've got some sweet markup), you'll need to have a look at the Views/Home/Index.cshtml and see | ||
which has a section like this: | ||
Ensure that strings is the current section selection. | ||
|
||
@section featured { | ||
<!-- bitching markup here --> | ||
} | ||
If your resource file is in a separate project you may wish to change the access modifier to public so you can access it from other projects. | ||
|
||
Because of that, we've got our own _Layout.Code52.cshtml file. Feel free to modify that to suit. | ||
::::::::::::::::::::::::::::::: | ||
2. Add reference to language selection UserControl | ||
::::::::::::::::::::::::::::::: | ||
|
||
--Cleanup-- | ||
Add the following reference to a page / layout that you wish to display the language selection. | ||
|
||
Lastly, to switch it back to how you had it, just change your Views/_Layout.cshtml file back to: | ||
@Html.Partial("LanguageSelection") | ||
|
||
@{ | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} | ||
::::::::::::::::::::::::::::::: | ||
3. Add JavaScript references | ||
::::::::::::::::::::::::::::::: | ||
|
||
|
||
Instruction | ||
----------- | ||
|
||
Add the following CSS / JavaScript references to your template or web page. | ||
|
||
<script src="@Url.Content("~/Scripts/jquery.globalize/globalize.js")" type="text/javascript"></script> | ||
<script src="@Url.Content(string.Format("~/Scripts/jquery.globalize/cultures/globalize.culture.{0}.js", CultureHelper.GetCurrentCulture()))" type="text/javascript"></script> | ||
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script> | ||
@if (CultureHelper.GetCurrentNeutralCulture() != "en") { | ||
<script type="text/javascript" src="@String.Format("http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/localization/messages_{0}.js", CultureHelper.GetCurrentNeutralCulture())"></script> | ||
} | ||
|
||
Add the following Code52 JavaScript references to your template or web page. | ||
|
||
<link href="@Url.Content("~/Content/code52.i18n/Code52.i18n.css")" rel="stylesheet" type="text/css" /> | ||
<script type="text/javascript" src="@Url.Content("/Scripts/Code52.i18n.js")"></script> | ||
<script type="text/javascript" src="@Url.Content("/i18n/Code52.i18n.language.js")"></script> | ||
<script type="text/javascript"> | ||
Code52.Language.Init('@CultureHelper.GetCurrentCulture()'); | ||
</script> | ||
|
||
Explanation | ||
------------ | ||
|
||
<script type="text/javascript" src="@Url.Content("/Scripts/Code52.i18n.js")"></script> | ||
|
||
This is the reference to the javascript that handles the language selection control and initialises localisation within javascript. | ||
|
||
<script type="text/javascript" src="@Url.Content("/i18n/Code52.i18n.language.js")"></script> | ||
|
||
This references the MVC action that generates a Javascript object from the Language resource file. | ||
|
||
<script type="text/javascript"> | ||
Code52.Language.Init('@CultureHelper.GetCurrentCulture()'); | ||
</script> | ||
|
||
This statement initialises localisation for the current culture. |
32 changes: 32 additions & 0 deletions
32
src/Code52.i18n.MVC/NuSpec/Content/Views/Shared/LanguageSelection.ascx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> | ||
<div id="placeholder-regions"> | ||
</div> | ||
<div id="i18n-options-container"> | ||
<div id="i18n-options"> | ||
<a title="International" href="#" id="currentlanguage_link"><span id="currentlanguage_text"> | ||
</span> <span id="expandSign">[+]</span> </a> | ||
</div> | ||
<div id="i18n-regions"> | ||
<ul> | ||
<li>Languages | ||
<ol> | ||
<li class="lang"> | ||
<div class="language language_EN"> | ||
<a id="langOption" title="English" class="en-GB" href="#">English</a> | ||
</div> | ||
</li> | ||
<li class="lang"> | ||
<div class="language language_FR"> | ||
<a title="français" href="#" class="fr-FR" href="#">Français</a> | ||
</div> | ||
</li> | ||
<li class="lang"> | ||
<div class="language language_FR"> | ||
<a title="français" href="#" class="pl-PL" href="#">Polish</a> | ||
</div> | ||
</li> | ||
</ol> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
param($installPath, $toolsPath, $package, $project) | ||
$path = [System.IO.Path] | ||
$readmefile = $path::Combine($path::GetDirectoryName($project.FileName), "App_Readme\Code52.i18n.MVC.readme.txt") | ||
$DTE.ItemOperations.OpenFile($readmefile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.