Skip to content

Commit

Permalink
Merge branch 'DC-Package2' of https://github.com/DavidChristiansen/in…
Browse files Browse the repository at this point in the history
…ternationalization-mvc4 into DavidChristiansen-DC-Package2
  • Loading branch information
shiftbot committed Mar 13, 2012
2 parents 9b2c558 + ddb8a2d commit 9c09dbe
Show file tree
Hide file tree
Showing 27 changed files with 317 additions and 1,172 deletions.
1 change: 0 additions & 1 deletion build.cmd
Expand Up @@ -16,7 +16,6 @@ if "%version%" == "" (
rmdir artifacts /S /Q
mkdir artifacts

.\build\nuget.exe pack src\Code52.i18n\NuSpec\Code52.i18n.nuspec -Version %VERSION% -OutputDirectory artifacts
.\build\nuget.exe pack src\Code52.i18n.MVC\NuSpec\Code52.i18n.MVC3.nuspec -Version %VERSION% -OutputDirectory artifacts
.\build\nuget.exe pack src\Code52.i18n.MVC\NuSpec\Code52.i18n.MVC4.nuspec -Version %VERSION% -OutputDirectory artifacts
.\build\nuget.exe pack src\Code52.i18n.MVC3.Example\NuSpec\Code52.i18n.MVC3.Example.Razor.nuspec -Version %VERSION% -OutputDirectory artifacts
Expand Down
5 changes: 3 additions & 2 deletions build.proj
Expand Up @@ -17,7 +17,8 @@
<Output ItemName='ProjectRootPath' TaskParameter='Include' />
</CreateItem>
<Message Text="Parsing Language.resx" Importance="High" />
<Exec Command="build\PsuedoizerConsole.exe &quot;%(ProjectRootPath.FullPath)\src\Sample.CSharp.MVC4.Razor\Resources\Language.resx&quot; &quot;%(ProjectRootPath.FullPath)\src\Sample.CSharp.MVC4.Razor\Resources\Language.pl.resx&quot;" />
<Exec Command="build\PsuedoizerConsole.exe &quot;%(ProjectRootPath.FullPath)\src\Code52.i18n.MVC3.Example\NuSpec\Content\Resources\Language.resx&quot; &quot;%(ProjectRootPath.FullPath)\src\Code52.i18n.MVC3.Example\NuSpec\Content\Resources\Language.pl.resx&quot;" />
<Exec Command="build\PsuedoizerConsole.exe &quot;%(ProjectRootPath.FullPath)\src\Code52.i18n.MVC4.Example\NuSpec\Content\Resources\Language.resx&quot; &quot;%(ProjectRootPath.FullPath)\src\Code52.i18n.MVC4.Example\NuSpec\Content\Resources\Language.pl.resx&quot;" />
</Target>

<Target Name="Compile">
Expand All @@ -27,7 +28,7 @@

<Target Name="CompileSample">
<Message Text=" ===========Compiling code===========" Importance="High" />
<MSBuild Projects="./src/Code52.i18n.Sample.sln" Properties="Configuration=$(Configuration)" />
<MSBuild Projects="./src/Code52.i18n.sln" Properties="Configuration=$(Configuration)" />
<CallTarget Targets="BuildTestResourceFile" Condition="'$(Configuration)'=='Debug'" />
</Target>

Expand Down
Binary file added docs/logo/ProjectIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logo/i18n logo.design
Binary file not shown.
Binary file added docs/logo/i18n logo_250.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/Code52.i18n.MVC/Code52.i18n.MVC.csproj
Expand Up @@ -35,6 +35,10 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<None Include="NuSpec\Code52.i18n.MVC4.nuspec" />
Expand All @@ -43,6 +47,7 @@
<None Include="NuSpec\Content\Code52.i18n\LanguageFilterAttribute.cs.pp" />
<None Include="NuSpec\Content\Code52.i18n\LocalizationHelpers.cs.pp" />
<None Include="NuSpec\Content\Controllers\LanguageController.cs.pp" />
<None Include="NuSpec\tools\install.ps1" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
Expand All @@ -56,6 +61,7 @@
<Content Include="NuSpec\Content\Content\code52.i18n\images\flags\it.png" />
<Content Include="NuSpec\Content\Content\code52.i18n\images\icon_international_map.png" />
<Content Include="NuSpec\Content\Content\code52.i18n\images\WorldHeader.png" />
<Content Include="NuSpec\Content\Views\Shared\LanguageSelection.ascx" />
</ItemGroup>
<ItemGroup>
<None Include="NuSpec\Code52.i18n.MVC3.nuspec" />
Expand Down
44 changes: 32 additions & 12 deletions src/Code52.i18n.MVC/NuSpec/Code52.i18n.MVC3.nuspec
@@ -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>
44 changes: 32 additions & 12 deletions src/Code52.i18n.MVC/NuSpec/Code52.i18n.MVC4.nuspec
@@ -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>
@@ -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.
@@ -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>&nbsp;<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>
4 changes: 4 additions & 0 deletions src/Code52.i18n.MVC/NuSpec/tools/install.ps1
@@ -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)
5 changes: 0 additions & 5 deletions src/Code52.i18n.MVC3.Example/Code52.i18n.MVC3.Example.csproj
Expand Up @@ -42,9 +42,6 @@
<ItemGroup>
<EmbeddedResource Include="NuSpec\Content\Resources\Books.pl.resx" />
<EmbeddedResource Include="NuSpec\Content\Resources\Books.resx" />
<EmbeddedResource Include="NuSpec\Content\Resources\Language.en-US.resx" />
<EmbeddedResource Include="NuSpec\Content\Resources\Language.fr.resx" />
<EmbeddedResource Include="NuSpec\Content\Resources\Language.resx" />
</ItemGroup>
<ItemGroup>
<None Include="NuSpec\Code52.i18n.MVC3.Example.Razor.nuspec" />
Expand All @@ -57,7 +54,6 @@
<None Include="NuSpec\Content\Models\Accounts\RegisterModel.cs.pp" />
<None Include="NuSpec\Content\Models\Book.cs.pp" />
<None Include="NuSpec\Content\Resources\Books.Designer.cs.pp" />
<None Include="NuSpec\Content\Resources\Language.Designer.cs.pp" />
<None Include="NuSpec\Content\Views\Account\ChangePassword.cshtml.pp" />
<None Include="NuSpec\Content\Views\Account\ChangePasswordSuccess.cshtml" />
<None Include="NuSpec\Content\Views\Account\Login.cshtml.pp" />
Expand All @@ -70,7 +66,6 @@
<None Include="NuSpec\Content\Views\Home\About.cshtml" />
<None Include="NuSpec\Content\Views\Home\Contact.cshtml" />
<None Include="NuSpec\Content\Views\Home\Index.cshtml" />
<None Include="NuSpec\Content\Views\Shared\_Layout.Code52.cshtml.pp" />
<None Include="NuSpec\Content\Views\Shared\_LoginPartial.cshtml" />
<None Include="NuSpec\tools\install.ps1" />
</ItemGroup>
Expand Down

0 comments on commit 9c09dbe

Please sign in to comment.