From 333b6fd9d9096d3bd3f423053950c5636073f9e5 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 27 Oct 2014 15:31:34 +0100 Subject: [PATCH] a working internationalization ... --- .../LocalizedText.Designer.cs | 16 +- ...lizedTextfr.resx => LocalizedText.fr.resx} | 3 +- web/App_GlobalResources/LocalizedText.resx | 5 +- web/App_GlobalResources/Resources.Designer.cs | 13 + web/AssemblyInfo.cs | 3 + web/Controllers/BlogsController.cs | 1 + web/Controllers/HomeController.cs | 36 +- web/Models/App.master | 47 +- web/Theme/style.css | 13 +- web/Views/Blogs/Post.aspx | 22 +- web/Views/Home/ReferencedAssemblies.aspx | 14 +- web/Views/Web.config | 1 + web/Web.config | 2 +- web/Web.csproj | 21 +- web/instdbws.sql | 596 +++++++++++++++++- 15 files changed, 670 insertions(+), 123 deletions(-) rename web/App_GlobalResources/{LocalizedTextfr.resx => LocalizedText.fr.resx} (76%) diff --git a/web/App_GlobalResources/LocalizedText.Designer.cs b/web/App_GlobalResources/LocalizedText.Designer.cs index 1e2ccc62..8c1c0ee1 100644 --- a/web/App_GlobalResources/LocalizedText.Designer.cs +++ b/web/App_GlobalResources/LocalizedText.Designer.cs @@ -15,7 +15,7 @@ namespace Yavsc.App_GlobalResources { [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class LocalizedText { + public class LocalizedText { private static System.Resources.ResourceManager resourceMan; @@ -26,7 +26,7 @@ namespace Yavsc.App_GlobalResources { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Resources.ResourceManager ResourceManager { + public static System.Resources.ResourceManager ResourceManager { get { if (object.Equals(null, resourceMan)) { System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Yavsc.App_GlobalResources.LocalizedText", typeof(LocalizedText).Assembly); @@ -37,7 +37,7 @@ namespace Yavsc.App_GlobalResources { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static System.Globalization.CultureInfo Culture { + public static System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -46,9 +46,15 @@ namespace Yavsc.App_GlobalResources { } } - internal static string Previe { + public static string Preview { get { - return ResourceManager.GetString("Previe", resourceCulture); + return ResourceManager.GetString("Preview", resourceCulture); + } + } + + public static string Welcome { + get { + return ResourceManager.GetString("Welcome", resourceCulture); } } } diff --git a/web/App_GlobalResources/LocalizedTextfr.resx b/web/App_GlobalResources/LocalizedText.fr.resx similarity index 76% rename from web/App_GlobalResources/LocalizedTextfr.resx rename to web/App_GlobalResources/LocalizedText.fr.resx index 04615cc8..2f3f7ca6 100644 --- a/web/App_GlobalResources/LocalizedTextfr.resx +++ b/web/App_GlobalResources/LocalizedText.fr.resx @@ -12,5 +12,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Previewcomment on preview + PrévisualiserPrévisualiser le document + Bienvenue diff --git a/web/App_GlobalResources/LocalizedText.resx b/web/App_GlobalResources/LocalizedText.resx index 1d1cb7d0..11fda7e5 100644 --- a/web/App_GlobalResources/LocalizedText.resx +++ b/web/App_GlobalResources/LocalizedText.resx @@ -12,7 +12,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 -this is my long stringthis is a comment -Blue - + Previewcomment on preview + Welcome diff --git a/web/App_GlobalResources/Resources.Designer.cs b/web/App_GlobalResources/Resources.Designer.cs index 031b9ff2..389eefd1 100644 --- a/web/App_GlobalResources/Resources.Designer.cs +++ b/web/App_GlobalResources/Resources.Designer.cs @@ -45,5 +45,18 @@ namespace Yavsc.App_GlobalResources { resourceCulture = value; } } + + internal static System.Drawing.Color Color1 { + get { + object obj = ResourceManager.GetObject("Color1", resourceCulture); + return ((System.Drawing.Color)(obj)); + } + } + + internal static string Name1 { + get { + return ResourceManager.GetString("Name1", resourceCulture); + } + } } } diff --git a/web/AssemblyInfo.cs b/web/AssemblyInfo.cs index 08760d78..120f0064 100644 --- a/web/AssemblyInfo.cs +++ b/web/AssemblyInfo.cs @@ -3,6 +3,7 @@ using System.Runtime.CompilerServices; // Information about this assembly is defined by the following attributes. // Change them to the values specific to your project. +using System.Resources; [assembly: AssemblyTitle("Yavsc")] [assembly: AssemblyDescription("")] @@ -13,6 +14,8 @@ using System.Runtime.CompilerServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] + + // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. diff --git a/web/Controllers/BlogsController.cs b/web/Controllers/BlogsController.cs index 9f24ca62..6b5d0f8a 100644 --- a/web/Controllers/BlogsController.cs +++ b/web/Controllers/BlogsController.cs @@ -143,6 +143,7 @@ namespace Yavsc.Controllers return UserPost (BlogManager.GetPost (postid)); } } + string prevstr = App_GlobalResources.LocalizedText.Preview; return UserPost (BlogManager.GetPost (user, title)); } diff --git a/web/Controllers/HomeController.cs b/web/Controllers/HomeController.cs index c972236a..07971e60 100644 --- a/web/Controllers/HomeController.cs +++ b/web/Controllers/HomeController.cs @@ -8,6 +8,9 @@ using System.Web.Configuration; using System.Web.Mvc; using System.Web.Mvc.Ajax; using Yavsc; +using System.Reflection; +using Yavsc.App_GlobalResources; +using System.Resources; namespace Yavsc.Controllers { @@ -41,6 +44,12 @@ namespace Yavsc.Controllers } } + public ActionResult ReferencedAssemblies() + { + AssemblyName[] model = GetType ().Assembly.GetReferencedAssemblies (); + + return View (model); + } private static string owneremail = null; /// @@ -60,33 +69,12 @@ namespace Yavsc.Controllers public ActionResult Index () { - InitCulture (); - ViewData ["Message"] = string.Format(T.GetString("Welcome")+"({0})",GetType ().Assembly.FullName); + string cn = CultureInfo.CurrentCulture.Name; + ViewData ["Message"] = + LocalizedText.ResourceManager.GetString("Welcome"); return View (); } - public void InitCulture() { - CultureInfo culture = null; - string defaultCulture = "fr"; - if (Request.UserLanguages==null) - culture = CultureInfo.CreateSpecificCulture(defaultCulture); - else - if (Request.UserLanguages.Length > 0) { - try { - culture = new CultureInfo (Request.UserLanguages [0]); - } - catch (Exception e) { - ViewData ["Message"] = e.ToString (); - culture = CultureInfo.CreateSpecificCulture(defaultCulture); - } - } - else culture = CultureInfo.CreateSpecificCulture(defaultCulture); - System.Threading.Thread.CurrentThread.CurrentUICulture = culture; - System.Threading.Thread.CurrentThread.CurrentCulture = culture; - string lcd = Server.MapPath ("./locale"); - Mono.Unix.Catalog.Init("i8n1", lcd ); - } - public ActionResult AOEMail (string reason, string body) { // requires valid owner and admin email? diff --git a/web/Models/App.master b/web/Models/App.master index f15053c5..37fe850f 100644 --- a/web/Models/App.master +++ b/web/Models/App.master @@ -12,38 +12,13 @@ - -
-
- - - <% if (Membership.GetUser()==null) { %> - <%= Html.ActionLink( YavscHelpers.SiteName, "Index", "Home" ) %> -<%= Html.ActionLink("Login", "Login", "Account", new { returnUrl=Request.Url.PathAndQuery }, null ) %> - -<% } else { %> -<%= HttpContext.Current.User.Identity.Name %> @ <%= Html.ActionLink( YavscHelpers.SiteName, "Index", "Home" ) %> - - <%= Html.ActionLink( "Poster", "Post", "Blogs" ) %> - <%= Html.ActionLink( "Profile", "Profile", "Account" ) %> - <%= Html.ActionLink( "Logout", "Logout", "Account", new { returnUrl=Request.Url.PathAndQuery }, null) %> - -<% } %> - - - -
- - -

- <%= Page.Title %> -

+

<%= Page.Title %>

- + <% if (ViewData["Error"]!=null) { %>
<%= Html.Encode(ViewData["Error"]) %> @@ -54,20 +29,26 @@ <%= Html.Encode(ViewData["Message"]) %>
<% } %> - - -
-
-