Translation service 56/174156/4
authorMichal Kolodziejski <m.kolodziejs@samsung.com>
Wed, 28 Mar 2018 14:17:41 +0000 (16:17 +0200)
committerMichal Kolodziejski <m.kolodziejs@samsung.com>
Thu, 5 Apr 2018 13:50:22 +0000 (15:50 +0200)
Change-Id: Ie02e613714d7af9cd9f721d37702b5fddcb1a116
Signed-off-by: Michal Kolodziejski <m.kolodziejs@samsung.com>
Clock/Clock.Tizen.Mobile/Clock.Tizen.Mobile.cs
Clock/Clock.Tizen.Mobile/Clock.Tizen.Mobile.csproj
Clock/Clock.Tizen.Mobile/Clock.Tizen.Mobile.csproj.orig [new file with mode: 0644]
Clock/Clock.Tizen.Mobile/Clock.xaml.cs
Clock/Clock.Tizen.Mobile/Clock.xaml.cs.orig [new file with mode: 0644]
Clock/Clock.Tizen.Mobile/Translation/Resources/AppResources.Designer.cs [new file with mode: 0644]
Clock/Clock.Tizen.Mobile/Translation/Resources/AppResources.resx [new file with mode: 0644]
Clock/Clock.Tizen.Mobile/Translation/TranslationService.cs [new file with mode: 0644]
Clock/Clock.Tizen.Mobile/Views/MainView.xaml
Clock/Clock.Tizen.Mobile/Views/MainView.xaml.orig [new file with mode: 0644]

index 9dfe7dc..84a0777 100644 (file)
@@ -6,16 +6,23 @@ namespace Clock.Tizen.Mobile
 {
     class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
     {
+        private App _application;
         private const string APP_CONTROL_DATA_ALARM_ID = "http://tizen.org/appcontrol/data/alarm_id";
 
         protected override void OnCreate()
         {
             base.OnCreate();
-            var application = new App
+            _application = new App
             {
                 ApplicationId = ApplicationInfo.ApplicationId
             };
-            LoadApplication(application);
+            LoadApplication(_application);
+        }
+
+        protected override void OnTerminate()
+        {
+            _application?.Deinitialize();
+            base.OnTerminate();
         }
 
         protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
index 999da25..0a26752 100644 (file)
     <Compile Update="Controls\GmtTimeLabel.xaml.cs">
       <DependentUpon>GmtTimeLabel.xaml</DependentUpon>
     </Compile>
+    <Compile Update="Translation\Resources\AppResources.Designer.cs">
+      <DesignTime>True</DesignTime>
+      <AutoGen>True</AutoGen>
+      <DependentUpon>AppResources.resx</DependentUpon>
+      </Compile>
     <Compile Update="Views\DeleteLocationsPage.xaml.cs">
       <DependentUpon>DeleteLocationsPage.xaml</DependentUpon>
     </Compile>
     <EmbeddedResource Update="Controls\TimeSelector.xaml">
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
     </EmbeddedResource>
+    <EmbeddedResource Update="Translation\Resources\AppResources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>AppResources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
     <EmbeddedResource Update="Views\AddEditAlarmPage.xaml">
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
     </EmbeddedResource>
diff --git a/Clock/Clock.Tizen.Mobile/Clock.Tizen.Mobile.csproj.orig b/Clock/Clock.Tizen.Mobile/Clock.Tizen.Mobile.csproj.orig
new file mode 100644 (file)
index 0000000..6bac443
--- /dev/null
@@ -0,0 +1,148 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <!-- Property Group for Tizen40 Project -->
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>tizen40</TargetFramework>
+  </PropertyGroup>
+
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugType>portable</DebugType>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>None</DebugType>
+  </PropertyGroup>
+  <ItemGroup>
+    <None Remove="**\*.xaml" />
+  </ItemGroup>
+
+  
+  <!-- If solution already has PCL project, will reference -->
+  <ItemGroup>
+    <ProjectReference Include="..\Clock\Clock.csproj" />
+  </ItemGroup>
+  
+
+  <!-- Include Nuget Package for Tizen Project building -->
+  <ItemGroup>
+    <PackageReference Include="Tizen.NET" Version="5.0.0.14275">
+      <ExcludeAssets>Runtime</ExcludeAssets>
+    </PackageReference>
+    <PackageReference Include="Tizen.NET.Sdk" Version="1.0.1" />
+    <PackageReference Include="Unity" Version="5.7.3" />
+    <PackageReference Include="Xamarin.Forms" Version="2.5.0.280555" />
+    <PackageReference Include="Xamarin.Forms.Platform.Tizen" Version="2.5.0.122203" />
+    <PackageReference Include="sqlite-net-base" Version="1.5.166-beta" />
+    <PackageReference Include="SQLitePCLRaw.core" Version="1.1.9" />
+    <PackageReference Include="SQLitePCLRaw.provider.sqlite3.netstandard11" Version="1.1.9" />
+  </ItemGroup>
+  <ItemGroup>
+    <Page Include="ResourceDictionary.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="SkiaSharp">
+      <HintPath>lib\SkiaSharp.dll</HintPath>
+    </Reference>
+    <Reference Include="SkiaSharp.Views.Forms">
+      <HintPath>lib\SkiaSharp.Views.Forms.dll</HintPath>
+    </Reference>
+    <Reference Include="SkiaSharp.Views.Tizen">
+      <HintPath>lib\SkiaSharp.Views.Tizen.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Update="**\*.xaml.cs">
+      <SubType>Code</SubType>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Update="Controls\GmtTimeLabel.xaml.cs">
+      <DependentUpon>GmtTimeLabel.xaml</DependentUpon>
+    </Compile>
+<<<<<<< HEAD
+    <Compile Update="Views\DeleteLocationsPage.xaml.cs">
+      <DependentUpon>DeleteLocationsPage.xaml</DependentUpon>
+=======
+    <Compile Update="Translation\Resources\AppResources.Designer.cs">
+      <DesignTime>True</DesignTime>
+      <AutoGen>True</AutoGen>
+      <DependentUpon>AppResources.resx</DependentUpon>
+>>>>>>> Translation service
+    </Compile>
+    <Compile Update="Views\WorldClockPage.xaml.cs">
+      <DependentUpon>WorldClockPage.xaml</DependentUpon>
+    </Compile>
+    <Compile Update="Controls\AmPmChooser.xaml.cs">
+      <DependentUpon>AmPmChooser.xaml</DependentUpon>
+    </Compile>
+    <Compile Update="Views\AddEditAlarmPage.xaml.cs">
+      <DependentUpon>AddEditAlarmPage.xaml</DependentUpon>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Update="Clock.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Controls\ClockMap.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Controls\DateSelector.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Controls\DateTimeSelector.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Controls\AmPmChooser.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Controls\Lists\MultiSelectList.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Controls\GmtTimeLabel.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\AddAlarmPage.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Controls\TimeSelector.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Translation\Resources\AppResources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>AppResources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\AddEditAlarmPage.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\AlarmListPage.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\AlarmView.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\DeleteLocationsPage.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\EditAlarmView.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\MainView.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\ReorderingPlacesView.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\StopWatchView.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\TimerView.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Update="Views\WorldClockPage.xaml">
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
+
+</Project>
index b8181de..2db117b 100644 (file)
@@ -9,6 +9,7 @@ using Clock.Tizen.Mobile.Factory;
 using Clock.Tizen.Mobile.Navigation;
 using Clock.Tizen.Mobile.Repositories;
 using Clock.Tizen.Mobile.Services;
+using Clock.Tizen.Mobile.Translation;
 using CommonServiceLocator;
 using Navigation.Tools.Navigation.Interfaces;
 using Tizen;
@@ -25,7 +26,7 @@ namespace Clock
     public partial class App
     {
         private UnityContainer _ioCContainer;
-
+        private readonly TranslationService _translationService;
         public const string Tag = "clock";
 
         public string ApplicationId { get; set; }
@@ -35,6 +36,10 @@ namespace Clock
             try
             {
                 InitializeComponent();
+
+                _translationService = new TranslationService("Clock.Tizen.Mobile.Translation.Resources.AppResources");
+                _translationService.Initialize();
+
                 MainPage = new NavigationPage();
                 InitializeIoC();
 
@@ -48,6 +53,11 @@ namespace Clock
             }
         }
 
+        public void Deinitialize()
+        {
+            _translationService?.Deinitialize();
+        }
+
         private void InitializeIoC()
         {
             _ioCContainer = new UnityContainer();
@@ -60,10 +70,12 @@ namespace Clock
         private void ConfigureIoCContainer()
         {
             _ioCContainer.RegisterType<IAlarmRepository, AlarmsRepository>(
-                new InjectionConstructor(Path.Combine(TizenApp.Current.DirectoryInfo.Data, ClockSettings.CLOCK_DATABASE_FILENAME),
+                new InjectionConstructor(
+                    Path.Combine(TizenApp.Current.DirectoryInfo.Data, ClockSettings.CLOCK_DATABASE_FILENAME),
                     typeof(ILogger)));
             _ioCContainer.RegisterType<ILocationsRepository, LocationsRepository>(
-                new InjectionConstructor(Path.Combine(TizenApp.Current.DirectoryInfo.Data, ClockSettings.CLOCK_DATABASE_FILENAME),
+                new InjectionConstructor(
+                    Path.Combine(TizenApp.Current.DirectoryInfo.Data, ClockSettings.CLOCK_DATABASE_FILENAME),
                     typeof(ILogger)));
             _ioCContainer.RegisterType<IPlatformAlarmsService, TizenPlatformAlarmService>();
             _ioCContainer.RegisterType<ITimerRepository, TimerRepository>();
@@ -81,4 +93,4 @@ namespace Clock
                 typeof(INavigationService)));
         }
     }
-}
+}
\ No newline at end of file
diff --git a/Clock/Clock.Tizen.Mobile/Clock.xaml.cs.orig b/Clock/Clock.Tizen.Mobile/Clock.xaml.cs.orig
new file mode 100644 (file)
index 0000000..95b9bb5
--- /dev/null
@@ -0,0 +1,103 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using Clock.Abstractions;
+using Clock.Abstractions.Repositories;
+using Clock.Data;
+using Clock.Services;
+using Clock.Tizen.Mobile.Factory;
+using Clock.Tizen.Mobile.Navigation;
+using Clock.Tizen.Mobile.Repositories;
+using Clock.Tizen.Mobile.Services;
+using Clock.Tizen.Mobile.Translation;
+using CommonServiceLocator;
+using Navigation.Tools.Navigation.Interfaces;
+using Tizen;
+using Unity;
+using Unity.Injection;
+using Unity.Lifetime;
+using Unity.ServiceLocation;
+using Xamarin.Forms;
+using AlarmManager = Clock.Services.AlarmManager;
+using TizenApp = Tizen.Applications.Application;
+
+namespace Clock
+{
+    public partial class App
+    {
+        private UnityContainer _ioCContainer;
+<<<<<<< HEAD
+
+        public const string Tag = "clock";
+=======
+        private readonly TranslationService _translationService;
+        public const string Tag = "d";
+>>>>>>> Translation service
+
+        public string ApplicationId { get; set; }
+
+        public App()
+        {
+            try
+            {
+                InitializeComponent();
+
+                _translationService = new TranslationService();
+                _translationService.Initialize();;
+
+                MainPage = new NavigationPage();
+                InitializeIoC();
+
+                (ServiceLocator.Current.GetInstance<INavigationService>() as ClockNavigationService)
+                    ?.NavigateToMainPage();
+            }
+            catch (Exception e)
+            {
+                Log.Error(Tag, $"{e.Message} {e.InnerException?.Message} {e.InnerException?.StackTrace}");
+                Debug.WriteLine(e);
+            }
+        }
+
+        public void Deinitialize()
+        {
+            _translationService?.Deinitialize();
+        }
+
+        private void InitializeIoC()
+        {
+            _ioCContainer = new UnityContainer();
+            ConfigureIoCContainer();
+
+            var unityServiceLocator = new UnityServiceLocator(_ioCContainer);
+            ServiceLocator.SetLocatorProvider(() => unityServiceLocator);
+        }
+
+        private void ConfigureIoCContainer()
+        {
+            _ioCContainer.RegisterType<IAlarmRepository, AlarmsRepository>(
+                new InjectionConstructor(Path.Combine(TizenApp.Current.DirectoryInfo.Data, ClockSettings.CLOCK_DATABASE_FILENAME),
+                    typeof(ILogger)));
+            _ioCContainer.RegisterType<ILocationsRepository, LocationsRepository>(
+                new InjectionConstructor(Path.Combine(TizenApp.Current.DirectoryInfo.Data, ClockSettings.CLOCK_DATABASE_FILENAME),
+                    typeof(ILogger)));
+            _ioCContainer.RegisterType<IPlatformAlarmsService, TizenPlatformAlarmService>();
+            _ioCContainer.RegisterType<ITimerRepository, TimerRepository>();
+            _ioCContainer.RegisterType<ILogger, TizenLogger>(new InjectionConstructor(Tag));
+            _ioCContainer.RegisterType<IPageFactory, PageFactory>(new SingletonLifetimeManager());
+            _ioCContainer.RegisterType<ISystemSettings, SystemSettings>();
+<<<<<<< HEAD
+            _ioCContainer.RegisterType<ILocationsManager, LocationsManager>(new SingletonLifetimeManager());
+            _ioCContainer.RegisterType<ITimeZonePickerService, TizenTimeZonePickerService>();
+=======
+            
+>>>>>>> Translation service
+            _ioCContainer.RegisterType<INavigationService, ClockNavigationService>(
+                new SingletonLifetimeManager(),
+                new InjectionConstructor(MainPage.Navigation, typeof(IPageFactory)));
+            _ioCContainer.RegisterType<AlarmManager>(new InjectionConstructor(
+                typeof(IPlatformAlarmsService),
+                typeof(IAlarmRepository),
+                typeof(INavigationService)));
+        }
+    }
+}
diff --git a/Clock/Clock.Tizen.Mobile/Translation/Resources/AppResources.Designer.cs b/Clock/Clock.Tizen.Mobile/Translation/Resources/AppResources.Designer.cs
new file mode 100644 (file)
index 0000000..0d420d0
--- /dev/null
@@ -0,0 +1,99 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     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.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Clock.Tizen.Mobile.Translation.Resources {
+    using System;
+    
+    
+    /// <summary>
+    ///   A strongly-typed resource class, for looking up localized strings, etc.
+    /// </summary>
+    // 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", "15.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class AppResources {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal AppResources() {
+        }
+        
+        /// <summary>
+        ///   Returns the cached ResourceManager instance used by this class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Clock.Tizen.Mobile.Translation.Resources.AppResources", typeof(AppResources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   Overrides the current thread's CurrentUICulture property for all
+        ///   resource lookups using this strongly typed resource class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Alarm.
+        /// </summary>
+        internal static string IDS_CLOCK_BODY_ALARM {
+            get {
+                return ResourceManager.GetString("IDS_CLOCK_BODY_ALARM", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Stopwatch.
+        /// </summary>
+        internal static string IDS_CLOCK_BODY_STOPWATCH {
+            get {
+                return ResourceManager.GetString("IDS_CLOCK_BODY_STOPWATCH", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Timer.
+        /// </summary>
+        internal static string IDS_CLOCK_BODY_TIMER {
+            get {
+                return ResourceManager.GetString("IDS_CLOCK_BODY_TIMER", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to World clock.
+        /// </summary>
+        internal static string IDS_CLOCK_BODY_WORLD_CLOCK {
+            get {
+                return ResourceManager.GetString("IDS_CLOCK_BODY_WORLD_CLOCK", resourceCulture);
+            }
+        }
+    }
+}
diff --git a/Clock/Clock.Tizen.Mobile/Translation/Resources/AppResources.resx b/Clock/Clock.Tizen.Mobile/Translation/Resources/AppResources.resx
new file mode 100644 (file)
index 0000000..d08900f
--- /dev/null
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <data name="IDS_CLOCK_BODY_ALARM" xml:space="preserve">
+    <value>Alarm</value>
+  </data>
+  <data name="IDS_CLOCK_BODY_STOPWATCH" xml:space="preserve">
+    <value>Stopwatch</value>
+  </data>
+  <data name="IDS_CLOCK_BODY_TIMER" xml:space="preserve">
+    <value>Timer</value>
+  </data>
+  <data name="IDS_CLOCK_BODY_WORLD_CLOCK" xml:space="preserve">
+    <value>World clock</value>
+  </data>
+</root>
\ No newline at end of file
diff --git a/Clock/Clock.Tizen.Mobile/Translation/TranslationService.cs b/Clock/Clock.Tizen.Mobile/Translation/TranslationService.cs
new file mode 100644 (file)
index 0000000..76007bb
--- /dev/null
@@ -0,0 +1,67 @@
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Reflection;
+using System.Resources;
+using Tizen.System;
+using Xamarin.Forms;
+using TizenSystemSettings = Tizen.System.SystemSettings;
+
+namespace Clock.Tizen.Mobile.Translation
+{
+    public class TranslationService
+    {
+        private static Lazy<ResourceManager> _resourceManager;
+
+        private static CultureInfo _cultureInfo =
+            CultureInfo.CreateSpecificCulture(TizenSystemSettings.LocaleLanguage.Replace("_", "-"));
+
+        public TranslationService(string resourceLocation)
+        {
+            _resourceManager = new Lazy<ResourceManager>(() =>
+                new ResourceManager(resourceLocation, typeof(TranslationService).GetTypeInfo().Assembly));
+        }
+
+        public void Initialize()
+        {
+            if (Application.Current.Resources == null)
+            {
+                Application.Current.Resources = new ResourceDictionary();
+            }
+
+            var resourceSet = _resourceManager.Value.GetResourceSet(_cultureInfo, true, true);
+            foreach (DictionaryEntry entry in resourceSet)
+            {
+                Application.Current.Resources.Add(entry.Key.ToString(), entry.Value.ToString());
+            }
+
+            TizenSystemSettings.LocaleLanguageChanged += SystemSettingsOnLocaleLanguageChanged;
+        }
+
+        public void Deinitialize()
+        {
+            TizenSystemSettings.LocaleLanguageChanged -= SystemSettingsOnLocaleLanguageChanged;
+        }
+
+        public string GetTranslation(string key)
+        {
+            return _resourceManager.Value.GetString(key) ?? "";
+        }
+
+        private void SystemSettingsOnLocaleLanguageChanged(object sender,
+            LocaleLanguageChangedEventArgs localeLanguageChangedEventArgs)
+        {
+            _cultureInfo = CultureInfo.CreateSpecificCulture(localeLanguageChangedEventArgs.Value.Replace("_", "-"));
+            ChangeAppLanguage();
+        }
+
+        private void ChangeAppLanguage()
+        {
+            var resourceSet = _resourceManager.Value.GetResourceSet(_cultureInfo, true, true);
+            foreach (DictionaryEntry entry in resourceSet)
+            {
+                Application.Current.Resources[entry.Key.ToString()] = entry.Value.ToString();
+            }
+        }
+    }
+}
\ No newline at end of file
index 33650e4..6d33f98 100644 (file)
@@ -8,20 +8,20 @@
 
     <TabbedPage.Children>
 
-        <pages:AlarmListPage Title="Alarm"
+        <pages:AlarmListPage Title="{DynamicResource IDS_CLOCK_BODY_ALARM}"
                              Icon="tabs/clock_tabs_ic_alarm.png" />
 
-        <pages:WorldClockPage  Title="World clock"
+        <pages:WorldClockPage  Title="{DynamicResource IDS_CLOCK_BODY_WORLD_CLOCK}"
                      Icon="tabs/clock_tabs_ic_worldclock.png"/>
 
-        <ContentPage Title="Stopwatch"
+        <ContentPage Title="{DynamicResource IDS_CLOCK_BODY_TIMER}"
                      Icon="tabs/clock_tabs_ic_stopwatch.png">
             <StackLayout>
                 <Label Text="Stopwatch Stub" />
             </StackLayout>
         </ContentPage>
 
-        <ContentPage Title="Timer"
+        <ContentPage Title="{DynamicResource IDS_CLOCK_BODY_STOPWATCH}"
                      Icon="tabs/clock_tabs_ic_timer.png">
             <StackLayout>
                 <Label Text="Timer Stub" />
@@ -29,4 +29,4 @@
         </ContentPage>
 
     </TabbedPage.Children>
-</TabbedPage>
\ No newline at end of file
+</TabbedPage>
diff --git a/Clock/Clock.Tizen.Mobile/Views/MainView.xaml.orig b/Clock/Clock.Tizen.Mobile/Views/MainView.xaml.orig
new file mode 100644 (file)
index 0000000..edb0da2
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
+            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+            xmlns:pages="clr-namespace:Clock.Tizen.Mobile.Views;assembly=Clock.Tizen.Mobile"
+            x:Class="Clock.Tizen.Mobile.Views.MainView"
+            Title="Test">
+
+    <TabbedPage.Children>
+
+        <pages:AlarmListPage Title="{DynamicResource IDS_CLOCK_BODY_ALARM}"
+                             Icon="tabs/clock_tabs_ic_alarm.png" />
+
+<<<<<<< HEAD
+        <pages:WorldClockPage  Title="World clock"
+                     Icon="tabs/clock_tabs_ic_worldclock.png"/>
+=======
+        <ContentPage Title="{DynamicResource IDS_CLOCK_BODY_WORLD_CLOCK}"
+                     Icon="tabs/clock_tabs_ic_worldclock.png">
+            <StackLayout>
+                <Label Text="World Clock Stub" />
+            </StackLayout>
+        </ContentPage>
+>>>>>>> Translation service
+
+        <ContentPage Title="{DynamicResource IDS_CLOCK_BODY_TIMER}"
+                     Icon="tabs/clock_tabs_ic_stopwatch.png">
+            <StackLayout>
+                <Label Text="Stopwatch Stub" />
+            </StackLayout>
+        </ContentPage>
+
+        <ContentPage Title="{DynamicResource IDS_CLOCK_BODY_STOPWATCH}"
+                     Icon="tabs/clock_tabs_ic_timer.png">
+            <StackLayout>
+                <Label Text="Timer Stub" />
+            </StackLayout>
+        </ContentPage>
+
+    </TabbedPage.Children>
+</TabbedPage>
\ No newline at end of file