From: amitpatel Date: Fri, 1 Dec 2023 13:33:33 +0000 (+0530) Subject: Added multilanguage support X-Git-Tag: accepted/tizen/unified/20231205.024715^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F84%2F302184%2F3;p=profile%2Fiot%2Fapps%2Fdotnet%2Fnotifications.git Added multilanguage support Change-Id: Id21d8aa091765c858f4ebc48246e4fe2bcc336d3 --- diff --git a/Notifications/Common/MultiResourceManager.cs b/Notifications/Common/MultiResourceManager.cs new file mode 100644 index 0000000..d14121b --- /dev/null +++ b/Notifications/Common/MultiResourceManager.cs @@ -0,0 +1,26 @@ +using System.Globalization; +using System.Reflection; +using System.Resources; + +namespace Notifications.Common +{ + public class MultiResourceManager : ResourceManager + { + public MultiResourceManager(string baseName, Assembly assembly) + : base(baseName, assembly) + { + } + + public override string GetString(string name) + { + return base.GetString(name) + ?? TextResources.Resources.ResourceManager.GetString(name); + } + + public override string GetString(string name, CultureInfo culture) + { + return base.GetString(name, culture) + ?? TextResources.Resources.ResourceManager.GetString(name, culture); + } + } +} diff --git a/Notifications/Notifications.cs b/Notifications/Notifications.cs index 02c127f..20fd029 100644 --- a/Notifications/Notifications.cs +++ b/Notifications/Notifications.cs @@ -14,11 +14,15 @@ * limitations under the License. */ +using System; using System.Collections.Generic; +using System.Globalization; using Tizen.Applications; using Tizen.NUI; using Notifications.Common; +using Tizen.NUI.BaseComponents; + namespace Notifications { class Program : NUIApplication @@ -39,6 +43,8 @@ namespace Notifications void Initialize() { Tizen.Log.Info(AppConstants.LogTag, "Program OnCreate"); + SetupLanguage(); + window = Window.Instance; window.SetTransparency(true); List list = new List @@ -93,6 +99,27 @@ namespace Notifications UpdateWindowPosition(); } + private void SetupLanguage() + { + void SetLanguage() + { + try + { + string language = Tizen.System.SystemSettings.LocaleLanguage.Replace("_", "-"); + var culture = CultureInfo.CreateSpecificCulture(language); + CultureInfo.CurrentCulture = culture; + TextResources.Resources.Culture = culture; + } + catch (Exception e) + { + Tizen.Log.Debug(AppConstants.LogTag, "Setting Language failed" + e.Message); + } + } + + MultilingualResourceManager = new MultiResourceManager("Notifications.TextResources.Resources", typeof(Resources).Assembly); + Tizen.System.SystemSettings.LocaleLanguageChanged += (s, e) => SetLanguage(); + SetLanguage(); + } protected override void OnAppControlReceived(AppControlReceivedEventArgs e) { base.OnAppControlReceived(e); diff --git a/Notifications/Notifications.csproj b/Notifications/Notifications.csproj index ba62547..e9d8331 100644 --- a/Notifications/Notifications.csproj +++ b/Notifications/Notifications.csproj @@ -16,6 +16,27 @@ + + + True + True + Resources.resx + + + + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + MSBuild:Compile diff --git a/Notifications/TextResources/Resources.Designer.cs b/Notifications/TextResources/Resources.Designer.cs new file mode 100644 index 0000000..eeb3c13 --- /dev/null +++ b/Notifications/TextResources/Resources.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Notifications.TextResources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Notifications.TextResources.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to You don't have notifications. + /// + public static string IDS_ST_BODY_NO_NOTIFICATIONS_MSG { + get { + return ResourceManager.GetString("IDS_ST_BODY_NO_NOTIFICATIONS_MSG", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear All. + /// + public static string IDS_ST_BUTTON_CLEAR_ALL { + get { + return ResourceManager.GetString("IDS_ST_BUTTON_CLEAR_ALL", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Notifications. + /// + public static string IDS_ST_HEADER_NOTIFICATIONS { + get { + return ResourceManager.GetString("IDS_ST_HEADER_NOTIFICATIONS", resourceCulture); + } + } + } +} diff --git a/Notifications/TextResources/Resources.en-US.resx b/Notifications/TextResources/Resources.en-US.resx new file mode 100644 index 0000000..2e09afe --- /dev/null +++ b/Notifications/TextResources/Resources.en-US.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + You don't have notifications + + + Clear All + + + Notifications + + \ No newline at end of file diff --git a/Notifications/TextResources/Resources.ko-KR.resx b/Notifications/TextResources/Resources.ko-KR.resx new file mode 100644 index 0000000..f74ef5c --- /dev/null +++ b/Notifications/TextResources/Resources.ko-KR.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 알림이 없습니다 + + + 클리어 올 + + + 알림 + + \ No newline at end of file diff --git a/Notifications/TextResources/Resources.resx b/Notifications/TextResources/Resources.resx new file mode 100644 index 0000000..2e09afe --- /dev/null +++ b/Notifications/TextResources/Resources.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + You don't have notifications + + + Clear All + + + Notifications + + \ No newline at end of file diff --git a/Notifications/Views/BaseView.cs b/Notifications/Views/BaseView.cs index 4ed0050..8c82e07 100644 --- a/Notifications/Views/BaseView.cs +++ b/Notifications/Views/BaseView.cs @@ -134,7 +134,7 @@ namespace Notifications.Views titleText = new TextLabel() { StyleName = "TitleText", - Text = "Notifications", + TranslatableText = "IDS_ST_HEADER_NOTIFICATIONS", HeightSpecification = LayoutParamPolicies.MatchParent, VerticalAlignment = VerticalAlignment.Center, }; @@ -192,6 +192,7 @@ namespace Notifications.Views if (clearAllButton == null) { clearAllButton = new Button("ClearAllButton"); + clearAllButton.TextLabel.TranslatableText = "IDS_ST_BUTTON_CLEAR_ALL"; RelativeLayout.SetVerticalAlignment(clearAllButton, RelativeLayout.Alignment.Center); RelativeLayout.SetHorizontalAlignment(clearAllButton, RelativeLayout.Alignment.End); clearAllButton.SetBinding(Control.CommandProperty, "ClearAllNotificationsCommand"); @@ -206,7 +207,7 @@ namespace Notifications.Views noNotificationsText = new TextLabel() { StyleName = "TitleText", - Text = "You don't have notifications", + TranslatableText = "IDS_ST_BODY_NO_NOTIFICATIONS_MSG", WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HorizontalAlignment = HorizontalAlignment.Center, @@ -216,6 +217,8 @@ namespace Notifications.Views Add(noNotificationsText); } + + private bool isContentAvailable; public bool IsContentAvailable { diff --git a/Notifications/res/themes/dark.xaml b/Notifications/res/themes/dark.xaml index cc25f78..c36f331 100644 --- a/Notifications/res/themes/dark.xaml +++ b/Notifications/res/themes/dark.xaml @@ -31,7 +31,7 @@ Id="DarkTheme"> - + diff --git a/Notifications/res/themes/light.xaml b/Notifications/res/themes/light.xaml index be3f645..672c5b0 100644 --- a/Notifications/res/themes/light.xaml +++ b/Notifications/res/themes/light.xaml @@ -31,7 +31,7 @@ Id="LightTheme"> - + diff --git a/packaging/org.tizen.notifications-1.0.0.tpk b/packaging/org.tizen.notifications-1.0.0.tpk index 8e47f9c..4fa35bb 100644 Binary files a/packaging/org.tizen.notifications-1.0.0.tpk and b/packaging/org.tizen.notifications-1.0.0.tpk differ