public async Task <IActionResult> GetAppLocalizationsScript([FromQuery] string langCodes, [FromQuery] string appIdentifiers)
        {
            string scriptContent;

            try
            {
                var localizationData = await AppLocalization.GetAppLocalizationsAsync(GetDefaultDbContext(),
                                                                                      (langCodes ?? string.Empty).Split(','), (appIdentifiers ?? string.Empty).Split(','));

                //Important - localization data MUST be serialized with casing intact as class namespaces are the keys to solving translations on the clientside
                var localizationDataSerialized = JsonConvert.SerializeObject(localizationData, Formatting.None);

                var replacementToken = "{HERE_GOES_LOCALE_DATA_DUDE}";

                var scriptStub = MapHive.Core.Configuration.WebClientConfiguration.GetConfigurationScript(
                    new Dictionary <string, object>
                {
                    { "localization", replacementToken }
                });

                scriptContent = scriptStub.Replace($"\"{replacementToken}\"", localizationDataSerialized);
            }
            catch (Exception ex)
            {
                scriptContent = MapHive.Core.Configuration.WebClientConfiguration
                                .GetConfigurationScriptFromException(ex);
            }

            return(new JavaScriptResult(scriptContent));
        }
 public async Task <IActionResult> GetAppLocalizations([FromQuery] string langCodes, [FromQuery] string appIdentifiers)
 {
     try
     {
         return(Ok(await AppLocalization.GetAppLocalizationsAsync(GetDefaultDbContext(), (langCodes ?? string.Empty).Split(','), (appIdentifiers ?? string.Empty).Split(','))));
     }
     catch (Exception ex)
     {
         return(HandleException(ex));
     }
 }
Example #3
0
 private ILocalization GetLocalizationStrings(AppLocalization local)
 {
     ILocalization loc;
     switch (local)
     {
     case AppLocalization.Russian:
     loc=new RuLocalization();
     break;
     default:
     loc=new EnLocalization();
     break;
     }
     return loc;
 }
        public async Task <IActionResult> BulkSaveAppLocalizations([FromBody] BulkSaveInput data)
        {
            try
            {
                await
                AppLocalization.SaveLocalizationsAsync(GetDefaultDbContext(), data.AppLocalizations, data.Overwrite, data.Upsert, data.LangsToImport);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
        }
Example #5
0
// Public

        public DefaultAppSettings()
        {
            autorun                     = false;
            height                      = 600;
            width                       = 800;
            localization                = AppLocalization.English;
            toolBarVisible              = true;
            listViewVisible             = true;
            listViewHorizontalAlignment = HorizontalElementAlign.Left;
            tabItemAlignment            = TabItemAlign.Top;
            statusBarVisible            = true;
            confirmClipboardClear       = true;
            confirmExit                 = true;
            showNotifyIcon              = true;
            trayMinimize                = true;
            showNotifications           = true;
        }
Example #6
0
        private ILocalization GetLocalizationStrings(AppLocalization local)
        {
            ILocalization loc;

            switch (local)
            {
            case AppLocalization.Russian:
                loc = new RuLocalization();
                break;

            default:
                loc = new EnLocalization();
                break;
            }

            return(loc);
        }
Example #7
0
 /// <summary>
 /// This method sets language of the main window
 /// </summary>  
 public void SetLanguage(AppLocalization local)
 {
     Settings.Localization=local;
     lang=GetLocalizationStrings(Settings.Localization);
 }
Example #8
0
 // Public
 public AppSettings()
 {
     CurrentUser=Registry.CurrentUser;
     Autorun=
     CurrentUser.OpenSubKey
     (
     @"Software\Microsoft\Windows\CurrentVersion\Run",
     true
     );
     AppKey=
     SafeRegistryMethods.GetRegistrySubKey
     (
     CurrentUser,
     @"Software\CW"
     );
     defSettings=new DefaultAppSettings();
     height=
     SafeRegistryMethods.GetIntValue
     (
     AppKey,
     "Height",
     defSettings.Height
     );
     if(height<0)
     height=defSettings.Height;
     width=
     SafeRegistryMethods.GetIntValue
     (
     AppKey,
     "Width",
     defSettings.Width
     );
     if(width<0)
     width=defSettings.Width;
     localization=
     SafeRegistryMethods.GetEnumValue
     (
     AppKey,
     "Localization",
     defSettings.Localization
     );
     confirmClipboardClear=
     SafeRegistryMethods.GetBoolValue
     (
     AppKey,
     "ConfirmClipboardClear",
     defSettings.ConfirmClipboardClear
     );
     confirmExit=
     SafeRegistryMethods.GetBoolValue
     (
     AppKey,
     "ConfirmExit",
     defSettings.ConfirmExit
     );
     showNotifyIcon=
     SafeRegistryMethods.GetBoolValue
     (
     AppKey,
     "ShowNotifyIcon",
     defSettings.ShowNotifyIcon
     );
     trayMinimize=
     SafeRegistryMethods.GetBoolValue
     (
     AppKey,
     "TrayMinimize",
     defSettings.TrayMinimize
     );
     showNotifications=
     SafeRegistryMethods.GetBoolValue
     (
     AppKey,
     "ShowNotifications",
     defSettings.ShowNotifications
     );
 }
Example #9
0
 // Public
 public DefaultAppSettings()
 {
     autorun=false;
     height=600;
     width=800;
     localization=AppLocalization.English;
     confirmClipboardClear=true;
     confirmExit=true;
     showNotifyIcon=true;
     trayMinimize=true;
     showNotifications=true;
 }
Example #10
0
 public LocalizationSwitcher()
 {
     Localization=default(AppLocalization);
 }
Example #11
0
// Public

        public AppSettings()
        {
            CurrentUser = Registry.CurrentUser;
            Autorun     =
                CurrentUser.OpenSubKey
                (
                    @"Software\Microsoft\Windows\CurrentVersion\Run",
                    true
                );
            AppKey =
                SafeRegistryMethods.GetRegistrySubKey
                (
                    CurrentUser,
                    @"Software\CW"
                );
            defSettings = new DefaultAppSettings();
            height      =
                SafeRegistryMethods.GetIntValue
                (
                    AppKey,
                    "Height",
                    defSettings.Height
                );
            if (height < 0)
            {
                height = defSettings.Height;
            }
            width =
                SafeRegistryMethods.GetIntValue
                (
                    AppKey,
                    "Width",
                    defSettings.Width
                );
            if (width < 0)
            {
                width = defSettings.Width;
            }
            localization =
                SafeRegistryMethods.GetEnumValue
                (
                    AppKey,
                    "Localization",
                    defSettings.Localization
                );
            toolBarVisible =
                SafeRegistryMethods.GetBoolValue
                (
                    AppKey,
                    "ToolBarVisible",
                    defSettings.ToolBarVisible
                );
            listViewVisible =
                SafeRegistryMethods.GetBoolValue
                (
                    AppKey,
                    "ListViewVisible",
                    defSettings.ListViewVisible
                );
            listViewHorizontalAlignment =
                SafeRegistryMethods.GetEnumValue
                (
                    AppKey,
                    "ListViewHorizontalAlignment",
                    defSettings.ListViewHorizontalAlignment
                );
            tabItemAlignment =
                SafeRegistryMethods.GetEnumValue
                (
                    AppKey,
                    "TabItemAlignment",
                    defSettings.TabItemAlignment
                );
            statusBarVisible =
                SafeRegistryMethods.GetBoolValue
                (
                    AppKey,
                    "StatusBarVisible",
                    defSettings.StatusBarVisible
                );
            confirmClipboardClear =
                SafeRegistryMethods.GetBoolValue
                (
                    AppKey,
                    "ConfirmClipboardClear",
                    defSettings.ConfirmClipboardClear
                );
            confirmExit =
                SafeRegistryMethods.GetBoolValue
                (
                    AppKey,
                    "ConfirmExit",
                    defSettings.ConfirmExit
                );
            showNotifyIcon =
                SafeRegistryMethods.GetBoolValue
                (
                    AppKey,
                    "ShowNotifyIcon",
                    defSettings.ShowNotifyIcon
                );
            trayMinimize =
                SafeRegistryMethods.GetBoolValue
                (
                    AppKey,
                    "TrayMinimize",
                    defSettings.TrayMinimize
                );
            showNotifications =
                SafeRegistryMethods.GetBoolValue
                (
                    AppKey,
                    "ShowNotifications",
                    defSettings.ShowNotifications
                );
        }
Example #12
0
 /// <summary>
 /// This method sets language of the main window
 /// </summary>
 public void SetLanguage(AppLocalization local)
 {
     Settings.Localization = local;
     lang = GetLocalizationStrings(Settings.Localization);
 }
Example #13
0
 public LocalizationSwitcher()
 {
     Localization = default(AppLocalization);
 }