From 40270ac21c2ad787562dae68b1d62e08e773de96 Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Thu, 27 Sep 2018 18:00:58 -0400 Subject: [PATCH 01/30] FLUID-6303: added new l10n panel, adjuster, enactor and panel template --- .../PrefsEditorTemplate-localization.html | 6 ++ .../preferences/js/LocalizationPanel.js | 67 +++++++++++++++++ .../js/LocalizationSpaceEnactor.js | 32 ++++++++ .../js/LocalizationSpaceSchemas.js | 75 +++++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 src/framework/preferences/html/PrefsEditorTemplate-localization.html create mode 100644 src/framework/preferences/js/LocalizationPanel.js create mode 100644 src/framework/preferences/js/LocalizationSpaceEnactor.js create mode 100644 src/framework/preferences/js/LocalizationSpaceSchemas.js diff --git a/src/framework/preferences/html/PrefsEditorTemplate-localization.html b/src/framework/preferences/html/PrefsEditorTemplate-localization.html new file mode 100644 index 0000000000..d91076d380 --- /dev/null +++ b/src/framework/preferences/html/PrefsEditorTemplate-localization.html @@ -0,0 +1,6 @@ +

+ + +

+

+ diff --git a/src/framework/preferences/js/LocalizationPanel.js b/src/framework/preferences/js/LocalizationPanel.js new file mode 100644 index 0000000000..0b61fe1a8f --- /dev/null +++ b/src/framework/preferences/js/LocalizationPanel.js @@ -0,0 +1,67 @@ +/* +Copyright 2018 OCAD University + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt +*/ + +var fluid_3_0_0 = fluid_3_0_0 || {}; + +(function ($, fluid) { + "use strict"; + + /*********************************** + * Preferences Editor Localization * + ***********************************/ + + /** + * A sub-component of fluid.prefs that renders the "localization" panel of the user preferences interface. + */ + fluid.defaults("fluid.prefs.panel.localization", { + gradeNames: ["fluid.prefs.panel"], + preferenceMap: { + "fluid.prefs.localization": { + "model.locale": "default" + } + }, + mergePolicy: { + "controlValues.localization": "replace", + "stringArrayIndex.localization": "replace" + }, + selectors: { + header: ".flc-prefsEditor-localization-header", + localization: ".flc-prefsEditor-localization", + label: ".flc-prefsEditor-localization-label", + localizationDescr: ".flc-prefsEditor-localization-descr" + }, + selectorsToIgnore: ["header"], + stringArrayIndex: { + localization: ["localization-default", "localization-en", "localization-es", "localization-fa", "localization-fr"] + }, + protoTree: { + label: {messagekey: "label"}, + localizationDescr: {messagekey: "description"}, + localization: { + optionnames: "${{that}.msgLookup.localization}", + optionlist: "${{that}.options.controlValues.localization}", + selection: "${value}", + decorators: { + type: "fluid", + func: "fluid.prefs.selectDecorator", + options: { + styles: "{that}.options.classnameMap.localization" + } + } + } + }, + classnameMap: null, // must be supplied by implementors + controlValues: { + localization: ["default", "en", "es", "fa", "fr"] + } + }); + +})(jQuery, fluid_3_0_0); diff --git a/src/framework/preferences/js/LocalizationSpaceEnactor.js b/src/framework/preferences/js/LocalizationSpaceEnactor.js new file mode 100644 index 0000000000..ba9486daea --- /dev/null +++ b/src/framework/preferences/js/LocalizationSpaceEnactor.js @@ -0,0 +1,32 @@ +/* +Copyright 2018 OCAD University + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt +*/ + +var fluid_3_0_0 = fluid_3_0_0 || {}; + +(function ($, fluid) { + "use strict"; + + /******************************************************************************* + * Localization + * + * The enactor to change the locale shown according to the value + *******************************************************************************/ + // Note that the implementors need to provide the container for this view component + fluid.defaults("fluid.prefs.enactor.localization", { + gradeNames: ["fluid.prefs.enactor"], + preferenceMap: { + "fluid.prefs.localization": { + "model.locale": "locale" + } + } + }); + +})(jQuery, fluid_3_0_0); diff --git a/src/framework/preferences/js/LocalizationSpaceSchemas.js b/src/framework/preferences/js/LocalizationSpaceSchemas.js new file mode 100644 index 0000000000..5c9907f98f --- /dev/null +++ b/src/framework/preferences/js/LocalizationSpaceSchemas.js @@ -0,0 +1,75 @@ +/* +Copyright 2018 OCAD University + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt +*/ + +var fluid_3_0_0 = fluid_3_0_0 || {}; + +(function (fluid) { + "use strict"; + + /******************************************************************************* + * Starter auxiliary schema grade + * + * Contains the settings for the localization preference + *******************************************************************************/ + + // Fine-tune the starter aux schema and add localization preference + fluid.defaults("fluid.prefs.auxSchema.localization", { + gradeNames: ["fluid.prefs.auxSchema"], + auxiliarySchema: { + "namespace": "fluid.prefs.constructed", + "terms": { + "templatePrefix": "../../framework/preferences/html/", + "messagePrefix": "../../framework/preferences/messages/" + }, + "template": "%templatePrefix/SeparatedPanelPrefsEditor.html", + "message": "%messagePrefix/prefsEditor.json", + localization: { + "type": "fluid.prefs.localization", + "classes": { + "default": "", + "en": "fl-locale-en", + "es": "fl-locale-", + "fa": "fl-locale-fa", + "fr": "fl-locale-fr" + }, + "enactor": { + "type": "fluid.prefs.enactor.localization", + "classes": "@localization.classes" + }, + "panel": { + "type": "fluid.prefs.panel.localization", + "container": ".flc-prefsEditor-localization", // the css selector in the template where the panel is rendered + "classnameMap": {"localization": "@localization.classes"}, + "template": "%templatePrefix/PrefsEditorTemplate-localization.html", + "message": "%messagePrefix/localization.json" + } + } + } + }); + + /******************************************************************************* + * Primary Schema + *******************************************************************************/ + + // add extra prefs to the starter primary schemas + + fluid.defaults("fluid.prefs.schemas.localization", { + gradeNames: ["fluid.prefs.schemas"], + schema: { + "fluid.prefs.localization": { + "type": "string", + "default": "default", + "enum": ["default", "English", "Farsi", "French", "Spanish"] + } + } + }); + +})(fluid_3_0_0); From 60ebce3a52c3249fdac74ebf79a40769f2163076 Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Fri, 28 Sep 2018 13:33:10 -0400 Subject: [PATCH 02/30] FLUID-6303: Cherry-picking work from BlueSlug --- .../js/{LocalizationSpaceEnactor.js => LocalizationEnactor.js} | 0 .../js/{LocalizationSpaceSchemas.js => LocalizationSchemas.js} | 0 src/framework/preferences/preferencesDependencies.json | 3 +++ 3 files changed, 3 insertions(+) rename src/framework/preferences/js/{LocalizationSpaceEnactor.js => LocalizationEnactor.js} (100%) rename src/framework/preferences/js/{LocalizationSpaceSchemas.js => LocalizationSchemas.js} (100%) diff --git a/src/framework/preferences/js/LocalizationSpaceEnactor.js b/src/framework/preferences/js/LocalizationEnactor.js similarity index 100% rename from src/framework/preferences/js/LocalizationSpaceEnactor.js rename to src/framework/preferences/js/LocalizationEnactor.js diff --git a/src/framework/preferences/js/LocalizationSpaceSchemas.js b/src/framework/preferences/js/LocalizationSchemas.js similarity index 100% rename from src/framework/preferences/js/LocalizationSpaceSchemas.js rename to src/framework/preferences/js/LocalizationSchemas.js diff --git a/src/framework/preferences/preferencesDependencies.json b/src/framework/preferences/preferencesDependencies.json index bb439956da..d24029defd 100644 --- a/src/framework/preferences/preferencesDependencies.json +++ b/src/framework/preferences/preferencesDependencies.json @@ -21,12 +21,14 @@ "./js/LetterSpacePanel.js", "./js/SelfVoicingPanel.js", "./js/SyllabificationPanel.js", + "./js/LocalizationPanel.js", "./js/WordSpacePanel.js", "./js/Enactors.js", "./js/CaptionsEnactor.js", "./js/LetterSpaceEnactor.js", "./js/SelfVoicingEnactor.js", "./js/SyllabificationEnactor.js", + "./js/LocalizationEnactor.js", "./js/WordSpaceEnactor.js", "./js/StarterGrades.js", "./js/ArrowScrolling.js", @@ -40,6 +42,7 @@ "./js/LetterSpaceSchemas.js", "./js/SelfVoicingSchemas.js", "./js/SyllabificationSchemas.js", + "./js/LocalizationSchemas.js", "./js/WordSpaceSchemas.js", "./js/Builder.js" ], From 8b8ef1933604b50091f9ddf292eacde9dda1c9dd Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Fri, 28 Sep 2018 14:38:12 -0400 Subject: [PATCH 03/30] FLUID-6303: removed "default" option from list of locales --- src/framework/preferences/js/LocalizationPanel.js | 6 +++--- src/framework/preferences/js/LocalizationSchemas.js | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/framework/preferences/js/LocalizationPanel.js b/src/framework/preferences/js/LocalizationPanel.js index 0b61fe1a8f..f13dee2fba 100644 --- a/src/framework/preferences/js/LocalizationPanel.js +++ b/src/framework/preferences/js/LocalizationPanel.js @@ -25,7 +25,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; gradeNames: ["fluid.prefs.panel"], preferenceMap: { "fluid.prefs.localization": { - "model.locale": "default" + "model.locale": "en" } }, mergePolicy: { @@ -40,7 +40,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; }, selectorsToIgnore: ["header"], stringArrayIndex: { - localization: ["localization-default", "localization-en", "localization-es", "localization-fa", "localization-fr"] + localization: ["localization-en", "localization-es", "localization-fa", "localization-fr"] }, protoTree: { label: {messagekey: "label"}, @@ -60,7 +60,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; }, classnameMap: null, // must be supplied by implementors controlValues: { - localization: ["default", "en", "es", "fa", "fr"] + localization: ["en", "es", "fa", "fr"] } }); diff --git a/src/framework/preferences/js/LocalizationSchemas.js b/src/framework/preferences/js/LocalizationSchemas.js index 5c9907f98f..f9236cb1f5 100644 --- a/src/framework/preferences/js/LocalizationSchemas.js +++ b/src/framework/preferences/js/LocalizationSchemas.js @@ -34,7 +34,6 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; localization: { "type": "fluid.prefs.localization", "classes": { - "default": "", "en": "fl-locale-en", "es": "fl-locale-", "fa": "fl-locale-fa", @@ -66,8 +65,8 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; schema: { "fluid.prefs.localization": { "type": "string", - "default": "default", - "enum": ["default", "English", "Farsi", "French", "Spanish"] + "default": "English", + "enum": ["English", "Farsi", "French", "Spanish"] } } }); From a8db3a3eb1b18c9d5c7177bdeccf42a4ae1a402e Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Fri, 28 Sep 2018 14:43:17 -0400 Subject: [PATCH 04/30] FLUID-6303: fixes to localization aux schema --- src/framework/preferences/js/LocalizationSchemas.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/framework/preferences/js/LocalizationSchemas.js b/src/framework/preferences/js/LocalizationSchemas.js index f9236cb1f5..2521c73261 100644 --- a/src/framework/preferences/js/LocalizationSchemas.js +++ b/src/framework/preferences/js/LocalizationSchemas.js @@ -24,7 +24,6 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; fluid.defaults("fluid.prefs.auxSchema.localization", { gradeNames: ["fluid.prefs.auxSchema"], auxiliarySchema: { - "namespace": "fluid.prefs.constructed", "terms": { "templatePrefix": "../../framework/preferences/html/", "messagePrefix": "../../framework/preferences/messages/" @@ -35,7 +34,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; "type": "fluid.prefs.localization", "classes": { "en": "fl-locale-en", - "es": "fl-locale-", + "es": "fl-locale-es", "fa": "fl-locale-fa", "fr": "fl-locale-fr" }, @@ -66,7 +65,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; "fluid.prefs.localization": { "type": "string", "default": "English", - "enum": ["English", "Farsi", "French", "Spanish"] + "enum": ["en", "fa", "fr", "es"] } } }); From 13752d3757e39d64996276311017c79fc652195d Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Fri, 28 Sep 2018 14:46:28 -0400 Subject: [PATCH 05/30] FLUID-6303: Cherry-picking work from BlueSlug --- demos/prefsFramework/html/SeparatedPanelPrefsEditor.html | 1 + .../prefsFramework/html/SeparatedPanelPrefsEditorWithTTS.html | 1 + demos/prefsFramework/index.html | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/demos/prefsFramework/html/SeparatedPanelPrefsEditor.html b/demos/prefsFramework/html/SeparatedPanelPrefsEditor.html index daec1cae2a..775ea606ef 100644 --- a/demos/prefsFramework/html/SeparatedPanelPrefsEditor.html +++ b/demos/prefsFramework/html/SeparatedPanelPrefsEditor.html @@ -1,6 +1,7 @@
    +
  • diff --git a/demos/prefsFramework/html/SeparatedPanelPrefsEditorWithTTS.html b/demos/prefsFramework/html/SeparatedPanelPrefsEditorWithTTS.html index 242409ac1f..367b9175d2 100644 --- a/demos/prefsFramework/html/SeparatedPanelPrefsEditorWithTTS.html +++ b/demos/prefsFramework/html/SeparatedPanelPrefsEditorWithTTS.html @@ -12,6 +12,7 @@
  • +
diff --git a/demos/prefsFramework/index.html b/demos/prefsFramework/index.html index 3834e1d7d0..775aa5c2a4 100644 --- a/demos/prefsFramework/index.html +++ b/demos/prefsFramework/index.html @@ -61,11 +61,13 @@ + + @@ -77,6 +79,7 @@ + @@ -103,6 +106,7 @@ "fluid.prefs.auxSchema.letterSpace", // this will add the letter space adjuster and enactor "fluid.prefs.auxSchema.wordSpace", // this will add the word space adjuster and enactor "demo.prefsEditor.auxSchema.syllabification", // this will add the syllabification adjuster and enactor + "fluid.prefs.auxSchema.localization", // this will add the localization adjuster and enactor "demo.prefsEditor.auxSchema.simplify", // this will add the simplify adjuster and enactor "demo.prefsEditor.progressiveEnhancement" // progressive enhancement - may add selfVoicing ], From 87e01cbaf72f47df1563b4cbde6354328a71d6df Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Fri, 28 Sep 2018 15:54:32 -0400 Subject: [PATCH 06/30] FLUID-6303: changed l10n classes from "..locale.." to "..localization.." --- src/framework/preferences/js/LocalizationSchemas.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/framework/preferences/js/LocalizationSchemas.js b/src/framework/preferences/js/LocalizationSchemas.js index 2521c73261..459bea268b 100644 --- a/src/framework/preferences/js/LocalizationSchemas.js +++ b/src/framework/preferences/js/LocalizationSchemas.js @@ -33,10 +33,10 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; localization: { "type": "fluid.prefs.localization", "classes": { - "en": "fl-locale-en", - "es": "fl-locale-es", - "fa": "fl-locale-fa", - "fr": "fl-locale-fr" + "en": "fl-localization-en", + "es": "fl-localization-es", + "fa": "fl-localization-fa", + "fr": "fl-localization-fr" }, "enactor": { "type": "fluid.prefs.enactor.localization", From 785be1f7a37cc340d1e2567fc7d04595fa16572e Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Fri, 28 Sep 2018 19:17:55 -0400 Subject: [PATCH 07/30] FLUID-6303: added tests for localization panel --- .../html/LocalizationPanel-test.html | 61 +++++++++ .../preferences/js/LocalizationPanelTests.js | 118 ++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 tests/framework-tests/preferences/html/LocalizationPanel-test.html create mode 100644 tests/framework-tests/preferences/js/LocalizationPanelTests.js diff --git a/tests/framework-tests/preferences/html/LocalizationPanel-test.html b/tests/framework-tests/preferences/html/LocalizationPanel-test.html new file mode 100644 index 0000000000..16634a483a --- /dev/null +++ b/tests/framework-tests/preferences/html/LocalizationPanel-test.html @@ -0,0 +1,61 @@ + + + + + Localization Panel Tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Localization Panel Test Suite

+

+
+

+
    + +
    + +
    + + + diff --git a/tests/framework-tests/preferences/js/LocalizationPanelTests.js b/tests/framework-tests/preferences/js/LocalizationPanelTests.js new file mode 100644 index 0000000000..08f8f3e6e6 --- /dev/null +++ b/tests/framework-tests/preferences/js/LocalizationPanelTests.js @@ -0,0 +1,118 @@ +/* +Copyright 2018 OCAD University + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt +*/ + +/* global fluid, jqUnit */ + +(function ($) { + "use strict"; + + fluid.registerNamespace("fluid.tests"); + + fluid.defaults("fluid.tests.prefs.panel.localization", { + gradeNames: ["fluid.prefs.panel.localization", "fluid.tests.panels.utils.defaultTestPanel", "fluid.tests.panels.utils.injectTemplates"], + messageBase: { + "label": "Localization", + "description": "Change the locale and/or language", + "localization-default": "Default", + "localization-en": "English", + "localization-en_CA": "English (Canada)", + "localization-en_US": "English (USA)", + "localization-es": "Spanish", + "localization-fa": "Farsi", + "localization-fr": "French" + }, + model: { + value: "en" + }, + resources: { + template: { + href: "../../../../src/framework/preferences/html/PrefsEditorTemplate-localization.html" + } + }, + classnameMap: { + "localization": { + "en": "fl-localization-en", + "es": "fl-localization-es", + "fa": "fl-localization-fa", + "fr": "fl-localization-fr" + } + } + }); + + fluid.defaults("fluid.tests.localizationPanelTests", { + gradeNames: ["fluid.test.testEnvironment"], + components: { + localization: { + type: "fluid.tests.prefs.panel.localization", + container: ".flc-localization", + createOnEvent: "{localizationTester}.events.onTestCaseStart" + }, + localizationTester: { + type: "fluid.tests.localizationTester" + } + } + }); + + fluid.defaults("fluid.tests.localizationTester", { + gradeNames: ["fluid.test.testCaseHolder"], + testOptions: { + expectedNumOfOptions: 4, + defaultValue: "en", + newValue: "fr" + }, + modules: [{ + name: "Test the localization settings panel", + tests: [{ + expect: 8, + name: "Test the rendering of the localization panel", + sequence: [{ + event: "{fluid.tests.localizationPanelTests localization}.events.afterRender", + priority: "last:testing", + listener: "fluid.tests.localizationTester.testDefault", + args: ["{localization}", "{that}.options.testOptions.expectedNumOfOptions", "{that}.options.testOptions.defaultValue"] + }, + { + func: "fluid.tests.panels.changeInput", + args: ["{localization}.dom.localization", "{that}.options.testOptions.newValue"] + }, + { + listener: "fluid.tests.panels.utils.checkModel", + args: ["value", "{localization}.model", "{that}.options.testOptions.newValue"], + spec: {path: "value", priority: "last:testing"}, + changeEvent: "{localization}.applier.modelChanged" + }] + }] + }] + }); + + fluid.tests.localizationTester.testDefault = function (that, expectedNumOfOptions, expectedLocale) { + var options = that.container.find("option"); + var messageBase = that.options.messageBase; + jqUnit.assertEquals("There are " + expectedNumOfOptions + " locales in the control", expectedNumOfOptions, options.length); + jqUnit.assertEquals("The first locale is " + expectedLocale, expectedLocale, options.filter(":selected").val()); + jqUnit.assertEquals("The label text is " + messageBase.label, messageBase.label, that.locate("label").text()); + jqUnit.assertEquals("The description text is " + messageBase.description, messageBase.description, that.locate("localizationDescr").text()); + + fluid.each(options, function (option) { + var css = that.options.classnameMap.localization[option.value]; + if (css) { + jqUnit.assertTrue("The option has appropriate css applied", $(option).hasClass(css)); + } + }); + }; + + $(document).ready(function () { + fluid.test.runTests([ + "fluid.tests.localizationPanelTests" + ]); + }); + +})(jQuery); From 0cbd65799b4cbf4e1ff0efdf633b38fb60ce3ded Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Mon, 1 Oct 2018 19:30:25 -0400 Subject: [PATCH 08/30] FLUID-6303: added preliminary tests for l10n enactor --- .../html/LocalizationEnactor-test.html | 57 ++++++ .../js/LocalizationEnactorTests.js | 170 ++++++++++++++++++ 2 files changed, 227 insertions(+) create mode 100644 tests/framework-tests/preferences/html/LocalizationEnactor-test.html create mode 100644 tests/framework-tests/preferences/js/LocalizationEnactorTests.js diff --git a/tests/framework-tests/preferences/html/LocalizationEnactor-test.html b/tests/framework-tests/preferences/html/LocalizationEnactor-test.html new file mode 100644 index 0000000000..b9d926be3e --- /dev/null +++ b/tests/framework-tests/preferences/html/LocalizationEnactor-test.html @@ -0,0 +1,57 @@ + + + + + Localization Enactor Tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Localization Enactor Test Suite

    +

    +
    +

    +
      +
      +
      + + diff --git a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js new file mode 100644 index 0000000000..3e566a0e66 --- /dev/null +++ b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js @@ -0,0 +1,170 @@ +/* +Copyright 2018 OCAD University + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt +*/ + +/* global fluid, jqUnit */ + +(function ($) { + "use strict"; + + fluid.registerNamespace("fluid.tests"); + + /******************************************************************************* + * Unit tests for fluid.prefs.enactor.localization + *******************************************************************************/ + + fluid.defaults("fluid.tests.prefs.enactor.localizationEnactor", { + gradeNames: ["fluid.prefs.enactor.localization"], + model: { + value: "en" + } + }); + + fluid.defaults("fluid.tests.localizationTests", { + gradeNames: ["fluid.test.testEnvironment"], + components: { + localization: { + type: "fluid.tests.prefs.enactor.localizationEnactor", + container: ".flc-localization", + createOnEvent: "{localizationTester}.events.onTestCaseStart" + }, + localizationTester: { + type: "fluid.tests.localizationTester" + } + } + }); + + fluid.defaults("fluid.tests.localizationTester", { + gradeNames: ["fluid.test.testCaseHolder"], + modules: [{ + name: "fluid.prefs.enactor.localization", + tests: [{ + expect: 5, + name: "Set localization", + sequence: [{ + listener: "jqUnit.assert", + event: "{localizationTests localization}.events.onCreate", + args: ["The localization enactor was created"] + }, + { + func: "fluid.tests.localizationTester.assertLocale", + args: ["{localization}", {value: "en"}] + }, + { + func: "{localization}.applier.change", + args: ["value", "fr"] + }, + { + changeEvent: "{localization}.applier.modelChanged", + spec: {path: "value", priority: "last:testing"}, + listener: "fluid.tests.localizationTester.assertLocale", + args: ["{localization}", {value: "fr"}] + }, + { + func: "{localization}.applier.change", + args: ["value", "es"] + }, + { + changeEvent: "{localization}.applier.modelChanged", + spec: {path: "value", priority: "last:testing"}, + listener: "fluid.tests.localizationTester.assertLocale", + args: ["{localization}", {value: "es"}] + }, + { + funcName: "fluid.tests.localizationTester.reset", + args: ["{localization}"] + }, + { + func: "fluid.tests.localizationTester.assertLocale", + args: ["{localization}", {value: ""}] + }] + }] + }] + }); + + fluid.tests.localizationTester.assertLocale = function (that, expectedModel) { + console.log(that.model) + jqUnit.assertDeepEq("The model value is set correctly: " + expectedModel.value, expectedModel, that.model); + }; + + fluid.defaults("fluid.tests.localizationExistingTests", { + gradeNames: ["fluid.test.testEnvironment"], + components: { + localization: { + type: "fluid.tests.prefs.enactor.localizationEnactor", + container: ".flc-localization-existing", + createOnEvent: "{localizationTester}.events.onTestCaseStart" + }, + localizationTester: { + type: "fluid.tests.localizationExistingTester" + } + } + }); + + fluid.defaults("fluid.tests.localizationExistingTester", { + gradeNames: ["fluid.test.testCaseHolder"], + modules: [{ + name: "fluid.prefs.enactor.localization", + tests: [{ + expect: 4, + name: "Set localization when existing localization present", + sequence: [{ + listener: "jqUnit.assert", + event: "{localizationExistingTests localization}.events.onCreate", + args: ["The localization enactor was created"] + }, + { + func: "fluid.tests.localizationTester.assertLocale", + args: ["{localization}", {value: "en"}] + }, + { + func: "{localization}.applier.change", + args: ["value", "fr"] + }, + { + changeEvent: "{localization}.applier.modelChanged", + spec: {path: "value", priority: "last:testing"}, + func: "fluid.tests.localizationTester.assertLocale", + args: ["{localization}", {value: "fr"}] + }, + { + func: "{localization}.applier.change", + args: ["value", "es"] + }, + { + changeEvent: "{localization}.applier.modelChanged", + spec: {path: "value", priority: "last:testing"}, + func: "fluid.tests.localizationTester.assertLocale", + args: ["{localization}", {value: "es"}] + }, + { + funcName: "fluid.tests.localizationTester.reset", + args: ["{localization}.container"] + }, + { + func: "fluid.tests.localizationTester.assertLocale", + args: ["{localization}", {value: ""}] + }] + }] + }] + }); + + fluid.tests.localizationTester.reset = function (that) { + that.model.value = ""; + }; + + $(document).ready(function () { + fluid.test.runTests([ + "fluid.tests.localizationTests", + "fluid.tests.localizationExistingTests" + ]); + }); + +})(jQuery); From 5e2d45796bd27e822647b4c5db897a43669133c4 Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Mon, 1 Oct 2018 20:06:43 -0400 Subject: [PATCH 09/30] FLUID-6303: Added l10n enactor event to be fired on model change --- src/framework/preferences/js/LocalizationEnactor.js | 12 +++++++++++- src/framework/preferences/js/LocalizationPanel.js | 3 ++- src/framework/preferences/js/LocalizationSchemas.js | 2 +- .../preferences/js/LocalizationEnactorTests.js | 8 +++----- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/framework/preferences/js/LocalizationEnactor.js b/src/framework/preferences/js/LocalizationEnactor.js index ba9486daea..bfe94d665f 100644 --- a/src/framework/preferences/js/LocalizationEnactor.js +++ b/src/framework/preferences/js/LocalizationEnactor.js @@ -24,7 +24,17 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; gradeNames: ["fluid.prefs.enactor"], preferenceMap: { "fluid.prefs.localization": { - "model.locale": "locale" + "model.value": "value" + } + }, + events: { + onLocalizationChangeRequested: null + }, + modelListeners: { + value: { + listener: "{that}.events.onLocalizationChangeRequested.fire", + args: ["{change}.value"], + namespace: "onLocalizationChangeRequested" } } }); diff --git a/src/framework/preferences/js/LocalizationPanel.js b/src/framework/preferences/js/LocalizationPanel.js index f13dee2fba..5466ee556a 100644 --- a/src/framework/preferences/js/LocalizationPanel.js +++ b/src/framework/preferences/js/LocalizationPanel.js @@ -25,7 +25,8 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; gradeNames: ["fluid.prefs.panel"], preferenceMap: { "fluid.prefs.localization": { - "model.locale": "en" + "model.value": "default", + "controlValues.localization": "enum" } }, mergePolicy: { diff --git a/src/framework/preferences/js/LocalizationSchemas.js b/src/framework/preferences/js/LocalizationSchemas.js index 459bea268b..14ef8cf72b 100644 --- a/src/framework/preferences/js/LocalizationSchemas.js +++ b/src/framework/preferences/js/LocalizationSchemas.js @@ -64,7 +64,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; schema: { "fluid.prefs.localization": { "type": "string", - "default": "English", + "default": "en", "enum": ["en", "fa", "fr", "es"] } } diff --git a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js index 3e566a0e66..c5c8a51a34 100644 --- a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js @@ -72,8 +72,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt args: ["value", "es"] }, { - changeEvent: "{localization}.applier.modelChanged", - spec: {path: "value", priority: "last:testing"}, + event: "{localization}.events.onLocalizationChangeRequested", listener: "fluid.tests.localizationTester.assertLocale", args: ["{localization}", {value: "es"}] }, @@ -139,9 +138,8 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt args: ["value", "es"] }, { - changeEvent: "{localization}.applier.modelChanged", - spec: {path: "value", priority: "last:testing"}, - func: "fluid.tests.localizationTester.assertLocale", + event: "{localization}.events.onLocalizationChangeRequested", + listener: "fluid.tests.localizationTester.assertLocale", args: ["{localization}", {value: "es"}] }, { From d229f401bed646f753ca460041db823b13188368 Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Mon, 1 Oct 2018 20:17:16 -0400 Subject: [PATCH 10/30] FLUID-6303: added checks for l10n change event arguments --- .../js/LocalizationEnactorTests.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js index c5c8a51a34..da02f0cac8 100644 --- a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js @@ -46,7 +46,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt modules: [{ name: "fluid.prefs.enactor.localization", tests: [{ - expect: 5, + expect: 6, name: "Set localization", sequence: [{ listener: "jqUnit.assert", @@ -73,7 +73,11 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt }, { event: "{localization}.events.onLocalizationChangeRequested", - listener: "fluid.tests.localizationTester.assertLocale", + listener: "jqUnit.assertEquals", + args: ["Event arguments are as expected", "es", "{arguments}.0"] + }, + { + funcName: "fluid.tests.localizationTester.assertLocale", args: ["{localization}", {value: "es"}] }, { @@ -112,7 +116,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt modules: [{ name: "fluid.prefs.enactor.localization", tests: [{ - expect: 4, + expect: 5, name: "Set localization when existing localization present", sequence: [{ listener: "jqUnit.assert", @@ -139,16 +143,12 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt }, { event: "{localization}.events.onLocalizationChangeRequested", - listener: "fluid.tests.localizationTester.assertLocale", - args: ["{localization}", {value: "es"}] + listener: "jqUnit.assertEquals", + args: ["Event arguments are as expected", "es", "{arguments}.0"] }, { - funcName: "fluid.tests.localizationTester.reset", - args: ["{localization}.container"] - }, - { - func: "fluid.tests.localizationTester.assertLocale", - args: ["{localization}", {value: ""}] + funcName: "fluid.tests.localizationTester.assertLocale", + args: ["{localization}", {value: "es"}] }] }] }] From a211c54275044c7d37a037d310d5f9546fa143d7 Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Mon, 1 Oct 2018 20:26:56 -0400 Subject: [PATCH 11/30] FLUID-6303: added checks for l10n change event arguments --- tests/framework-tests/preferences/js/LocalizationEnactorTests.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js index da02f0cac8..60d1cc3b45 100644 --- a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js @@ -93,7 +93,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt }); fluid.tests.localizationTester.assertLocale = function (that, expectedModel) { - console.log(that.model) jqUnit.assertDeepEq("The model value is set correctly: " + expectedModel.value, expectedModel, that.model); }; From 6026bc21714672579aa5c119972f7e0728ba3267 Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Tue, 2 Oct 2018 20:22:56 -0400 Subject: [PATCH 12/30] FLUID-6303: corrected function call in l10n panel test sequence --- .../framework-tests/preferences/js/LocalizationPanelTests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/framework-tests/preferences/js/LocalizationPanelTests.js b/tests/framework-tests/preferences/js/LocalizationPanelTests.js index 08f8f3e6e6..001720da92 100644 --- a/tests/framework-tests/preferences/js/LocalizationPanelTests.js +++ b/tests/framework-tests/preferences/js/LocalizationPanelTests.js @@ -71,7 +71,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt modules: [{ name: "Test the localization settings panel", tests: [{ - expect: 8, + expect: 9, name: "Test the rendering of the localization panel", sequence: [{ event: "{fluid.tests.localizationPanelTests localization}.events.afterRender", @@ -80,7 +80,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt args: ["{localization}", "{that}.options.testOptions.expectedNumOfOptions", "{that}.options.testOptions.defaultValue"] }, { - func: "fluid.tests.panels.changeInput", + func: "fluid.changeElementValue", args: ["{localization}.dom.localization", "{that}.options.testOptions.newValue"] }, { From eaa6cee189330fc9277eb83b0f56234a0aa99b0f Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Tue, 2 Oct 2018 20:37:44 -0400 Subject: [PATCH 13/30] FLUID-6303: Cherry-Picking work from BlueSlug --- tests/framework-tests/preferences/all-tests.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/framework-tests/preferences/all-tests.html b/tests/framework-tests/preferences/all-tests.html index 6fedd2895a..26e9756bef 100644 --- a/tests/framework-tests/preferences/all-tests.html +++ b/tests/framework-tests/preferences/all-tests.html @@ -19,6 +19,7 @@ "./html/LetterSpaceEnactor-test.html", "./html/SelfVoicingEnactor-test.html", "./html/SyllabificationEnactor-test.html", + "./html/LocalizationEnactor-test.html", "./html/WordSpaceEnactor-test.html", "./html/SeparatedPanelPrefsEditor-test.html", "./html/SeparatedPanelPrefsEditorResponsive-test.html", @@ -30,6 +31,7 @@ "./html/LetterSpacePanel-test.html", "./html/SelfVoicingPanel-test.html", "./html/SyllabificationPanel-test.html", + "./html/LocalizationPanel-test.html", "./html/WordSpacePanel-test.html", "./html/PrimaryBuilder-test.html", "./html/Store-test.html", From 458b3b7f6a74d18f5e398a4329b666311e0d060a Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Wed, 3 Oct 2018 21:22:09 -0400 Subject: [PATCH 14/30] FLUID-6303: Cherry-Picking work from BlueSlug --- demos/uiOptionsLocalized/index.html | 268 +++++++++++++++++++++++++ demos/uiOptionsLocalized/js/uioDemo.js | 51 +++++ 2 files changed, 319 insertions(+) create mode 100644 demos/uiOptionsLocalized/index.html create mode 100644 demos/uiOptionsLocalized/js/uioDemo.js diff --git a/demos/uiOptionsLocalized/index.html b/demos/uiOptionsLocalized/index.html new file mode 100644 index 0000000000..feee2f911a --- /dev/null +++ b/demos/uiOptionsLocalized/index.html @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + Preferences Editor Localized Demo: Using Schemas + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +
      + +
      + + + + +
      + + +
      + + +
      + + + + +
      +
      + + + + +
      +
      + + +
      +
      + +
      +

      Preferences Editor

      +
      This page might be a bit difficult to read or use.
      + Why don't you consider using the display preferences option?
      +
      +
      +

      Some helpful tips

      +
        +
      1. Preference Editor and its different configurations.
        + On this page, Preference Editor can be found along the top edge. + There are other layout options in development - see Preference Editor Design Wireframes.
      2. +
      3. Try tinkering with the options.
      4. +
      +
      +
      +
      +

      Introduction

      + an orange +

      + Aliquam varius lacus non arcu venenatis scelerisque quis in sapien. + Curabitur nec felis tortor. + Cras euismod ipsum erat. + Sed ac lacus dolor, sed vestibulum sem. + Donec tristique lacinia augue. + In mollis venenatis mollis. + Duis facilisis fermentum accumsan. + Quisque aliquet eros at nunc volutpat euismod. +

      +

      + Pellentesque dictum mattis sapien a consectetur. + In hac habitasse platea dictumst. + Integer pharetra accumsan euismod. + Morbi congue leo eu diam bibendum luctus. + Ut quam orci, rhoncus sed fermentum eget, tempus rhoncus justo. + Donec gravida lorem vel orci aliquam vitae tristique ipsum pulvinar. + Sed lorem orci, gravida ac tristique at, aliquam eget massa. +

      +

      + In diam lorem, consequat vel lobortis non, pretium in leo. + Cras ut dolor ac nunc pharetra venenatis id at orci. + Nam a nibh id lectus dignissim molestie. + Donec est arcu, luctus eu tempor quis, posuere non risus. +

      +

      Why do oranges taste better than apples?

      +

      + Aliquam mattis placerat odio. + Aliquam sodales euismod sodales. + Integer mollis nulla eget quam imperdiet vitae elementum sapien adipiscing. +

      +
      +
      +

      + Sed tempus laoreet facilisis. + Curabitur at augue in justo tincidunt cursus. + Aliquam iaculis libero vel dolor fringilla a rutrum nisl tempus. +

      +

      + Cras lorem nulla, tincidunt nec dapibus id, interdum pellentesque elit. + Sed faucibus posuere augue, ac vehicula dolor feugiat id. + Ut scelerisque mollis aliquam. + Nulla facilisi. + Vestibulum porttitor pulvinar mauris et placerat. + Donec ultrices, eros eget pharetra eleifend, risus orci iaculis leo, nec facilisis nisi odio et nunc. +

      +

      + Sed varius sem sed sapien cursus vel iaculis nisl rhoncus. + Fusce placerat sapien ut erat mollis vestibulum. + Aenean eget tellus sem. +

      + +

      Some people actually prefer apples

      + an apple +

      + Praesent vulputate, sem vel feugiat iaculis, eros diam condimentum nisl, eget suscipit nunc est vitae justo. + Vivamus imperdiet convallis laoreet. + Quisque eget magna vitae tortor egestas imperdiet. +

      +

      + Donec at ipsum magna. + Suspendisse potenti. + Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. + Mauris vel eros eu purus sodales rutrum. + Suspendisse potenti. +

      + +
      +
      +

      + Fusce vel massa vitae dui sollicitudin adipiscing eget sed velit. + Fusce auctor vehicula turpis non faucibus. + Sed faucibus mollis enim venenatis mollis. + Morbi cursus scelerisque ornare. + Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. + Cras at cursus nisl. +

      +

      Conclusion: Oranges are still yummier

      +

      + Praesent consequat laoreet tellus, quis molestie dui pretium sit amet. + Donec et turpis vitae tortor blandit tristique eu sed justo. + Fusce in quam sem, ac hendrerit nisl. + Mauris consequat tellus in est vehicula placerat. + Sed sed ornare quam. + Quisque vel faucibus augue. + Donec euismod tellus a risus fringilla congue. + Proin feugiat, mauris ut ullamcorper pharetra, sem nulla lacinia nunc, ut hendrerit justo urna malesuada libero. + Pellentesque viverra fringilla arcu, consectetur interdum sapien tempus sed. + Donec tincidunt consequat libero, quis vulputate magna ullamcorper. +

      +
      +
      +

      Leave some feedback

      + +
      +
      +
      + + diff --git a/demos/uiOptionsLocalized/js/uioDemo.js b/demos/uiOptionsLocalized/js/uioDemo.js new file mode 100644 index 0000000000..b1c614a389 --- /dev/null +++ b/demos/uiOptionsLocalized/js/uioDemo.js @@ -0,0 +1,51 @@ +/* +Copyright 2018 OCAD University + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt +*/ + +var fluid_3_0_0 = fluid_3_0_0 || {}; +(function ($, fluid) { + "use strict"; + + fluid.defaults("fluid.uiOptions.prefsEditor.localizedDemoControls", { + gradeNames: ["fluid.viewComponent"], + events: { + onLocaleChangeRequested: "{fluid.uiOptions.prefsEditor.localized}.events.onInterfaceLocaleChangeRequested" + }, + selectors: { + languageLinkEnglish: ".flc-languages-en", + languageLinkSpanish: ".flc-languages-es", + languageLinkFarsi: ".flc-languages-fa", + languageLinkFrench: ".flc-languages-fr" + }, + listeners: { + "onCreate.bindLanguageLinkEnglish": { + "this": "{that}.dom.languageLinkEnglish", + "method": "click", + "args": ["en", "{that}.events.onLocaleChangeRequested.fire"] + }, + "onCreate.bindLanguageLinkSpanish": { + "this": "{that}.dom.languageLinkSpanish", + "method": "click", + "args": ["es", "{that}.events.onLocaleChangeRequested.fire"] + }, + "onCreate.bindLanguageLinkFarsi": { + "this": "{that}.dom.languageLinkFarsi", + "method": "click", + "args": ["fa", "{that}.events.onLocaleChangeRequested.fire"] + }, + "onCreate.bindLanguageLinkFrench": { + "this": "{that}.dom.languageLinkFrench", + "method": "click", + "args": ["fr", "{that}.events.onLocaleChangeRequested.fire"] + } + } + }); + +})(jQuery, fluid_3_0_0); From 151e67120d09f6cc5167cd9c50612bb4cecd544e Mon Sep 17 00:00:00 2001 From: BlueSlug Date: Thu, 4 Oct 2018 13:45:26 -0400 Subject: [PATCH 15/30] FLUID-6303: added l10n panel to localized UIO demo page, custom template --- .../html/SeparatedPanelPrefsEditor.html | 13 +++++++++++++ demos/uiOptionsLocalized/index.html | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 demos/uiOptionsLocalized/html/SeparatedPanelPrefsEditor.html diff --git a/demos/uiOptionsLocalized/html/SeparatedPanelPrefsEditor.html b/demos/uiOptionsLocalized/html/SeparatedPanelPrefsEditor.html new file mode 100644 index 0000000000..5a0a800c18 --- /dev/null +++ b/demos/uiOptionsLocalized/html/SeparatedPanelPrefsEditor.html @@ -0,0 +1,13 @@ +
      +
      +
        +
      • +
      • +
      • +
      • +
      • +
      • +
      • +
      +
      +
      diff --git a/demos/uiOptionsLocalized/index.html b/demos/uiOptionsLocalized/index.html index feee2f911a..5be1aec117 100644 --- a/demos/uiOptionsLocalized/index.html +++ b/demos/uiOptionsLocalized/index.html @@ -66,6 +66,9 @@ + + + @@ -78,6 +81,13 @@ + + - diff --git a/examples/framework/preferences/localizationPreference/es/index.html b/examples/framework/preferences/localizationPreference/es/index.html new file mode 100644 index 0000000000..77edadabf9 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/es/index.html @@ -0,0 +1,105 @@ + + + + + + + + + + + + + Editor de preferencias: Preferencia de localización + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +
      + + + + +
      + + +
      + + +
      + + + + +
      +
      + + +

      Hola Mundo!

      + + + + diff --git a/examples/framework/preferences/localizationPreference/fa/index.html b/examples/framework/preferences/localizationPreference/fa/index.html new file mode 100644 index 0000000000..7927451187 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/fa/index.html @@ -0,0 +1,105 @@ + + + + + + + + + + + + + ویرایشگر ترجیحات: اولویت محلی سازی + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +
      + + + + +
      + + +
      + + +
      + + + + +
      +
      + + +

      سلام دنیا!

      + + + + diff --git a/examples/framework/preferences/localizationPreference/fr/index.html b/examples/framework/preferences/localizationPreference/fr/index.html new file mode 100644 index 0000000000..9fd5fdadf4 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/fr/index.html @@ -0,0 +1,105 @@ + + + + + + + + + + + + + Editeur de préférences: Préférence de localisation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +
      + + + + +
      + + +
      + + +
      + + + + +
      +
      + + +

      Bonjour le monde!

      + + + + diff --git a/examples/framework/preferences/localizationPreference/html/prefsEditor.html b/examples/framework/preferences/localizationPreference/html/prefsEditor.html new file mode 100644 index 0000000000..3151a4f650 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/html/prefsEditor.html @@ -0,0 +1,7 @@ +
      +
      +
        +
      • +
      +
      +
      diff --git a/examples/framework/preferences/localizationPreference/index.html b/examples/framework/preferences/localizationPreference/index.html new file mode 100644 index 0000000000..4c962a13e7 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/index.html @@ -0,0 +1,104 @@ + + + + + + + + + + + + + Preferences Editor: Localization Preference + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      + +
      + + + + +
      + + +
      + + +
      + + + + +
      +
      + + +

      Hello World!

      + + + + diff --git a/examples/framework/preferences/localizationPreference/js/localization.js b/examples/framework/preferences/localizationPreference/js/localization.js new file mode 100644 index 0000000000..aa06994b06 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/js/localization.js @@ -0,0 +1,65 @@ +/* +Copyright 2018 OCAD University + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt +*/ + +/* global fluid */ + +var example = example || {}; +(function ($, fluid) { + "use strict"; + + fluid.prefs.builder({ + gradeNames: ["fluid.prefs.auxSchema.localization"], + auxiliarySchema: { + "namespace": "example.prefs.localization" + } + }); + + fluid.defaults("example.prefsEditor", { + gradeNames: ["example.prefs.localization.prefsEditor"], + localizationOpts: { + enactor: { + localizationScheme: "urlPath", + langMap: { + "default": null, + "en": "", + "es": "es", + "fa": "fa", + "fr": "fr" + }, + langSegIndex: 6 + }, + panel: { + controlValues: { + localization: ["default", "en", "fr", "es", "fa"] + } + } + }, + distributeOptions: { + "example.localization.defaultLocale": { + source: "{that}.options.defaultLocale", + target: "{that prefsEditorLoader}.options.defaultLocale" + }, + "example.localization.localizationEnactor": { + source: "{that}.options.localizationOpts.enactor", + target: "{that uiEnhancer fluid.prefs.enactor.localization}.options" + }, + "example.localization.localizationPanel": { + source: "{that}.options.localizationOpts.panel", + target: "{that prefsEditor fluid.prefs.panel.localization}.options" + }, + "example.localization.template": { + source: "{that}.options.template", + target: "{that prefsEditorLoader > templateLoader}.options.resources.prefsEditor" + } + } + }); + +})(jQuery, fluid); diff --git a/src/framework/preferences/css/stylus/PrefsEditor.styl b/src/framework/preferences/css/stylus/PrefsEditor.styl index 2fa0ba94de..5e1c44f578 100644 --- a/src/framework/preferences/css/stylus/PrefsEditor.styl +++ b/src/framework/preferences/css/stylus/PrefsEditor.styl @@ -211,7 +211,7 @@ .fl-icon-line-space-condensed, .fl-icon-contrast, .fl-icon-undo, .fl-icon-line-space, .fl-icon-inputs, .fl-icon-simplify, .fl-icon-font, .fl-icon-size, .fl-icon-text-to-speech, .fl-icon-toc, .fl-icon-letter-space, .fl-icon-letter-space-expanded, .fl-icon-letter-space-condensed, .fl-icon-captions, .fl-icon-word-space, - .fl-icon-word-space-condensed, .fl-icon-word-space-expanded, .fl-icon-syllabification { + .fl-icon-word-space-condensed, .fl-icon-word-space-expanded, .fl-icon-syllabification, .fl-icon-language { font-family: 'PrefsFramework-Icons'; speak: none; font-style: normal; @@ -325,6 +325,9 @@ .fl-icon-syllabification:before { content: "\e017"; } + .fl-icon-language:before { + content: "\e018"; + } } // Theming build-themes-prefsEditor(themes); diff --git a/src/framework/preferences/fonts/PrefsFramework-Icons-config.json b/src/framework/preferences/fonts/PrefsFramework-Icons-config.json index e187a57f62..f987ccdd9c 100644 --- a/src/framework/preferences/fonts/PrefsFramework-Icons-config.json +++ b/src/framework/preferences/fonts/PrefsFramework-Icons-config.json @@ -9,6 +9,7 @@ "svg/infusion/infusion-crossout-diag-dotted-line.svg", "svg/infusion/infusion-font-style.svg", "svg/infusion/infusion-indicator-arrow-triangle.svg", + "svg/infusion/infusion-language.svg", "svg/infusion/infusion-line-space.svg", "svg/infusion/infusion-line-space-condensed.svg", "svg/infusion/infusion-line-space-expanded.svg", @@ -51,7 +52,8 @@ "infusion-word-space": "0xE014", "infusion-word-space-condensed": "0xE015", "infusion-word-space-expanded": "0xE016", - "infusion-syllabification": "0xE017" + "infusion-syllabification": "0xE017", + "infusion-language": "0xE018" }, "templateOptions": { "classPrefix": "fl-icon-" diff --git a/src/framework/preferences/fonts/PrefsFramework-Icons.woff b/src/framework/preferences/fonts/PrefsFramework-Icons.woff index 756c7b6b7b4d88d38cb86553e063563d74ef8801..f0da76944f6996b2e6e4c8b5432de735d23b4fec 100644 GIT binary patch delta 5927 zcmY+IWmFVy(Ds+5Wa$M7sRfp9K^keKr8}1HmRe#dDe2AyB_yT0msT1Skd}~65$T8j z`#xWuIp=roxn{08_k5l?(ZbgV-?s`105rf;&_Mu1|Gh%?|6l)?|KCth&{2ExVLVk| zJV71FO!nc8oV)@6K)d^&eu5Uj0$_Nn&GQlfKwEy&%1^*}eyB=WxmdUZ06?85E%Vfq z0T6EXTlu_8MsNtyu0Iu@{Vzmz&i=Ll0L};i0R9dDK>YmbREq6wEUce~oS!_rPY4o! zkz!3=XVjI#`U=o;cC)g08i;#pi2jEoEo|Av!td!fw9Y3D`46-sprfmWi_O!Lg-`nS zX%p_xX7NhyZeH&I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j~t%{7>_%h{Wo?XRJR8wo1?XejkDs)EWQB6FXGz% z|4wLCmNm*kKXNpbQsdptw(|SuW(nls`lm>fue!GjtDD|{2CqarTb&D*8~o=js7CT^ z6PsD{W|R?#8rawInJb_2oStuQ@z>^)Ya};Pozrn@2CsQ)v^dQC_aeWsx|9W|_t~F_VKVMvrasW&%uaeA=!tS0)>Lq)cIm||A^GXZniKj5 zUbOMMUr0&WD4eHfJhoeZ0jSBS4>G9DP;vNG<4jSezG$zs&iu^bu!~#)uUdB!G*heh z7fyKY=oyiDNa;>h#bG6Sn=pJ{AH+K8>urs_hYF+9`XyOnew&YYno$0kALY`b$|tIp zRHkRER^H`l<);2|I1}HmL1kRJx;?AnKUy@wnlW5ger@adACBG_<=I#EElIeGoDpo^)5+p2 z(A$D272t%}?yYNoJi=CC(VeQnF337|8Akm#yG8zf{GjrwT6jFfCSUNUgiO2pB=b@1 zQYUmCTKc|hyq*eYB4yPA+SFXv@Z-RY^9kAfvsL=bhRZKMSa(J5Wddvc_nSoeI(`Jf z1<9LW1%b{|oH0WIlFe7QSsh$<3MSS5Il0H}9cj%CcfrB-I~;OX_tH!6uua{NVdZXU zzul0s+<;4ND6O+mcwWWm!EF&pI9s%|n}o`IA&Vk!(T}*s%T5&p{Bg=sR>@Qmdd5lz zM;|HwRAEu6Ns#Q|8{~x0JQ?NL;&D_01${9MgRZ+ diff --git a/src/framework/preferences/html/PrefsEditorTemplate-localization.html b/src/framework/preferences/html/PrefsEditorTemplate-localization.html index d91076d380..85042b8595 100644 --- a/src/framework/preferences/html/PrefsEditorTemplate-localization.html +++ b/src/framework/preferences/html/PrefsEditorTemplate-localization.html @@ -1,5 +1,5 @@

      - +

      diff --git a/src/framework/preferences/js/LocalizationEnactor.js b/src/framework/preferences/js/LocalizationEnactor.js index bfe94d665f..4d2db41702 100644 --- a/src/framework/preferences/js/LocalizationEnactor.js +++ b/src/framework/preferences/js/LocalizationEnactor.js @@ -18,25 +18,135 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; * Localization * * The enactor to change the locale shown according to the value + * + * This grade is resolvable from the root to allow for setting up of model relays + * from other components on a page that may want to be notified of a language + * change and update their own UI automatically. *******************************************************************************/ - // Note that the implementors need to provide the container for this view component + fluid.defaults("fluid.prefs.enactor.localization", { - gradeNames: ["fluid.prefs.enactor"], + gradeNames: ["fluid.prefs.enactor", "fluid.contextAware", "fluid.resolveRoot"], preferenceMap: { "fluid.prefs.localization": { - "model.value": "value" + "model.lang": "value" + } + }, + contextAwareness: { + localeChange: { + checks: { + inPanel: { + contextValue: "{iframeRenderer}" + }, + urlPath: { + contextValue: "{localization}.options.localizationScheme", + equals: "urlPath", + gradeNames: "fluid.prefs.enactor.localization.urlPathLocale", + priority: "after:inPanel" + } + }, + defaultGradeNames: "fluid.prefs.enactor.localization.no-op" } + } + }); + + /******************************************************************************* + * URL Path + * + * Changes the URL path to specify which language should be displayed. Useful + * if languages are served at different URLs based on a language resource. + * E.g. www.example.com/about/ -> www.example.com/fr/about/ + *******************************************************************************/ + fluid.defaults("fluid.prefs.enactor.localization.urlPathLocale", { + langMap: {}, // must be supplied by integrator + langSegIndex: 1, + model: { + urlPathname: undefined }, - events: { - onLocalizationChangeRequested: null + listeners: { + "onCreate.setURLPath": { + changePath: "urlPathname", + value: { + expander: { + func: "{that}.pathname" + } + }, + source: "initialURLPathname" + } }, modelListeners: { - value: { - listener: "{that}.events.onLocalizationChangeRequested.fire", + lang: { + funcName: "fluid.prefs.enactor.localization.urlPathLocale.changeLocale", + args: ["{that}", "{change}.value", "{that}.options.langMap", "{that}.options.langSegIndex"], + namespace: "langToURLPath" + }, + urlPathname: { + funcName: "{that}.pathname", args: ["{change}.value"], - namespace: "onLocalizationChangeRequested" + excludeSource: ["init", "initialURLPathname"], + namespace: "setURLPathname" } + }, + invokers: { + pathname: "fluid.prefs.enactor.localization.urlPathLocale.pathname" } }); + /** + * A simple wrapper around the location.pathname setter/getter property. + * + * @param {String} pathname - (Optional) pathname to set. If not supplied the current pathname will be returned + * @return {String} - If the `pathname` argument is not provided, the current pathname is returned + */ + fluid.prefs.enactor.localization.urlPathLocale.pathname = function (pathname) { + if (fluid.isValue(pathname)) { + location.pathname = pathname; + } else { + return location.pathname; + } + }; + + /** + * Modifies the URL Path to navigate to the specified localized version of the page. If the "default" language is + * selected. The function exits without modifying the URL. This allows for the server to automatically, or the user + * to manually, navigate to a localized page when a language preference hasn't been set. + * + * @param {Component} that - an instance of `fluid.prefs.enactor.localization.urlPathLocale` + * @param {String} lang - a language code for the requested language + * @param {Object} langMap - a mapping of language code to URL path resource. This handles cases where the format + * is different, or if the primary language is served from the root. + * @param {Integer} langSegIndex - An optional index into the path where the language resource identifier is held. + * By default this value is 1, which represents the first path segment. + */ + fluid.prefs.enactor.localization.urlPathLocale.changeLocale = function (that, lang, langMap, langSegIndex) { + + // Do nothing when the default language is chosen. + if (lang === "default") { + return; + } + + langSegIndex = langSegIndex || 1; + var pathname = that.model.urlPathname; + var pathSegs = pathname.split("/"); + var currentLang = pathSegs[langSegIndex]; + var hasLang = currentLang && fluid.values(langMap).indexOf(currentLang) >= 0; + var newLangSeg = langMap[lang]; + + if (hasLang) { + if (newLangSeg) { + pathSegs[langSegIndex] = newLangSeg; + } else { + if (langSegIndex === pathSegs.length - 1) { + pathSegs[langSegIndex] = ""; + } else { + pathSegs.splice(langSegIndex, 1); + } + } + } else if (newLangSeg) { + pathSegs.splice(langSegIndex, 0, newLangSeg); + } + + var newPathname = pathSegs.join("/"); + that.applier.change("urlPathname", newPathname, "ADD", "changeLocale"); + }; + })(jQuery, fluid_3_0_0); diff --git a/src/framework/preferences/js/LocalizationPanel.js b/src/framework/preferences/js/LocalizationPanel.js index 5466ee556a..279b05c898 100644 --- a/src/framework/preferences/js/LocalizationPanel.js +++ b/src/framework/preferences/js/LocalizationPanel.js @@ -25,7 +25,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; gradeNames: ["fluid.prefs.panel"], preferenceMap: { "fluid.prefs.localization": { - "model.value": "default", + "model.value": "value", "controlValues.localization": "enum" } }, @@ -41,7 +41,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; }, selectorsToIgnore: ["header"], stringArrayIndex: { - localization: ["localization-en", "localization-es", "localization-fa", "localization-fr"] + localization: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"] }, protoTree: { label: {messagekey: "label"}, @@ -49,19 +49,11 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; localization: { optionnames: "${{that}.msgLookup.localization}", optionlist: "${{that}.options.controlValues.localization}", - selection: "${value}", - decorators: { - type: "fluid", - func: "fluid.prefs.selectDecorator", - options: { - styles: "{that}.options.classnameMap.localization" - } - } + selection: "${value}" } }, - classnameMap: null, // must be supplied by implementors controlValues: { - localization: ["en", "es", "fa", "fr"] + localization: ["default", "en", "fr", "es", "fa"] } }); diff --git a/src/framework/preferences/js/LocalizationSchemas.js b/src/framework/preferences/js/LocalizationSchemas.js index 14ef8cf72b..86d0688e3b 100644 --- a/src/framework/preferences/js/LocalizationSchemas.js +++ b/src/framework/preferences/js/LocalizationSchemas.js @@ -32,12 +32,6 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; "message": "%messagePrefix/prefsEditor.json", localization: { "type": "fluid.prefs.localization", - "classes": { - "en": "fl-localization-en", - "es": "fl-localization-es", - "fa": "fl-localization-fa", - "fr": "fl-localization-fr" - }, "enactor": { "type": "fluid.prefs.enactor.localization", "classes": "@localization.classes" @@ -45,7 +39,6 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; "panel": { "type": "fluid.prefs.panel.localization", "container": ".flc-prefsEditor-localization", // the css selector in the template where the panel is rendered - "classnameMap": {"localization": "@localization.classes"}, "template": "%templatePrefix/PrefsEditorTemplate-localization.html", "message": "%messagePrefix/localization.json" } @@ -64,8 +57,8 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; schema: { "fluid.prefs.localization": { "type": "string", - "default": "en", - "enum": ["en", "fa", "fr", "es"] + "default": "default", + "enum": ["default", "en", "en_CA", "en_US", "fr", "es", "fa"] } } }); diff --git a/src/framework/preferences/js/SeparatedPanelPrefsEditor.js b/src/framework/preferences/js/SeparatedPanelPrefsEditor.js index a8d63d410b..e17bd589b1 100644 --- a/src/framework/preferences/js/SeparatedPanelPrefsEditor.js +++ b/src/framework/preferences/js/SeparatedPanelPrefsEditor.js @@ -131,7 +131,8 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; options: { gradeNames: ["{pageEnhancer}.uiEnhancer.options.userGrades"], jQuery: "{iframeRenderer}.jQuery", - tocTemplate: "{pageEnhancer}.uiEnhancer.options.tocTemplate" + tocTemplate: "{pageEnhancer}.uiEnhancer.options.tocTemplate", + inSeparatedPanel: true } } } diff --git a/src/framework/preferences/messages/localization.json b/src/framework/preferences/messages/localization.json index 569d65896b..6996c13604 100644 --- a/src/framework/preferences/messages/localization.json +++ b/src/framework/preferences/messages/localization.json @@ -3,9 +3,9 @@ "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", - "localization-es": "Spanish", - "localization-fa": "Farsi", - "localization-fr": "French", + "localization-es": "Español", + "localization-fa": "فارسی", + "localization-fr": "Français", "label": "Localization", "description": "Change the locale and/or language" } diff --git a/src/framework/preferences/messages/localization_en.json b/src/framework/preferences/messages/localization_en.json index 569d65896b..6996c13604 100644 --- a/src/framework/preferences/messages/localization_en.json +++ b/src/framework/preferences/messages/localization_en.json @@ -3,9 +3,9 @@ "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", - "localization-es": "Spanish", - "localization-fa": "Farsi", - "localization-fr": "French", + "localization-es": "Español", + "localization-fa": "فارسی", + "localization-fr": "Français", "label": "Localization", "description": "Change the locale and/or language" } diff --git a/src/framework/preferences/messages/localization_en_CA.json b/src/framework/preferences/messages/localization_en_CA.json index 569d65896b..6996c13604 100644 --- a/src/framework/preferences/messages/localization_en_CA.json +++ b/src/framework/preferences/messages/localization_en_CA.json @@ -3,9 +3,9 @@ "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", - "localization-es": "Spanish", - "localization-fa": "Farsi", - "localization-fr": "French", + "localization-es": "Español", + "localization-fa": "فارسی", + "localization-fr": "Français", "label": "Localization", "description": "Change the locale and/or language" } diff --git a/src/framework/preferences/messages/localization_en_US.json b/src/framework/preferences/messages/localization_en_US.json index 569d65896b..6996c13604 100644 --- a/src/framework/preferences/messages/localization_en_US.json +++ b/src/framework/preferences/messages/localization_en_US.json @@ -3,9 +3,9 @@ "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", - "localization-es": "Spanish", - "localization-fa": "Farsi", - "localization-fr": "French", + "localization-es": "Español", + "localization-fa": "فارسی", + "localization-fr": "Français", "label": "Localization", "description": "Change the locale and/or language" } diff --git a/src/framework/preferences/messages/localization_es.json b/src/framework/preferences/messages/localization_es.json index 162b40a0d2..02e5accc18 100644 --- a/src/framework/preferences/messages/localization_es.json +++ b/src/framework/preferences/messages/localization_es.json @@ -1,11 +1,11 @@ { "localization-default": "Defecto", - "localization-en": "Inglés", - "localization-en_CA": "Inglés (Canadá)", - "localization-en_US": "Inglés (Estados Unidos)", + "localization-en": "English", + "localization-en_CA": "English (Canada)", + "localization-en_US": "English (USA)", "localization-es": "Español", - "localization-fa": "Persa", - "localization-fr": "Francés", + "localization-fa": "فارسی", + "localization-fr": "Français", "label": "Localisation", "description": "Ajustar la localización o el idioma" } diff --git a/src/framework/preferences/messages/localization_fa.json b/src/framework/preferences/messages/localization_fa.json new file mode 100644 index 0000000000..ce5b5164a8 --- /dev/null +++ b/src/framework/preferences/messages/localization_fa.json @@ -0,0 +1,11 @@ +{ + "localization-default": "پیش فرض", + "localization-en": "English", + "localization-en_CA": "English (Canada)", + "localization-en_US": "English (USA)", + "localization-es": "Español", + "localization-fa": "فارسی", + "localization-fr": "Français", + "label": "بومی سازی", + "description": "تغییر زبان و / یا زبان" +} diff --git a/src/framework/preferences/messages/localization_fr.json b/src/framework/preferences/messages/localization_fr.json index 7703ce6443..22143a5ede 100644 --- a/src/framework/preferences/messages/localization_fr.json +++ b/src/framework/preferences/messages/localization_fr.json @@ -1,10 +1,10 @@ { "localization-default": "Défault", - "localization-en": "Anglais", - "localization-en_CA": "Anglais (Canada)", - "localization-en_US": "Anglais (États-Unis)", - "localization-es": "Espagnol", - "localization-fa": "Persan", + "localization-en": "English", + "localization-en_CA": "English (Canada)", + "localization-en_US": "English (USA)", + "localization-es": "Español", + "localization-fa": "فارسی", "localization-fr": "Français", "label": "Localisation", "description": "Ajuster la localisation ou la langue" diff --git a/tests/framework-tests/preferences/html/LocalizationEnactor-test.html b/tests/framework-tests/preferences/html/LocalizationEnactor-test.html index b9d926be3e..7fa553463b 100644 --- a/tests/framework-tests/preferences/html/LocalizationEnactor-test.html +++ b/tests/framework-tests/preferences/html/LocalizationEnactor-test.html @@ -51,7 +51,5 @@

        -
        -
        diff --git a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js index 60d1cc3b45..0a7ec14f24 100644 --- a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js @@ -23,17 +23,43 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt fluid.defaults("fluid.tests.prefs.enactor.localizationEnactor", { gradeNames: ["fluid.prefs.enactor.localization"], model: { - value: "en" - } + lang: "default" + }, + langMap: { + en: "", + fr: "fr-ca" + }, + pathnames: { + original: "/about/", + english: "/about/", + french: "/fr-ca/about/" + }, + localizationScheme: "urlPath", + langSegIndex: 1 }); + fluid.tests.prefs.enactor.localizationEnactor.pathname = function (that, pathname) { + if (fluid.isValue(pathname)) { + that.options.recordedPathname = pathname; + } else { + return that.options.recordedPathname || that.options.pathnames.original; + } + }; + fluid.defaults("fluid.tests.localizationTests", { gradeNames: ["fluid.test.testEnvironment"], components: { localization: { type: "fluid.tests.prefs.enactor.localizationEnactor", - container: ".flc-localization", - createOnEvent: "{localizationTester}.events.onTestCaseStart" + createOnEvent: "{localizationTester}.events.onTestCaseStart", + options: { + invokers: { + pathname: { + funcName: "fluid.tests.prefs.enactor.localizationEnactor.pathname", + args: ["{that}", "{arguments}.0"] + } + } + } }, localizationTester: { type: "fluid.tests.localizationTester" @@ -46,8 +72,8 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt modules: [{ name: "fluid.prefs.enactor.localization", tests: [{ - expect: 6, - name: "Set localization", + expect: 13, + name: "Localization", sequence: [{ listener: "jqUnit.assert", event: "{localizationTests localization}.events.onCreate", @@ -55,108 +81,144 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt }, { func: "fluid.tests.localizationTester.assertLocale", - args: ["{localization}", {value: "en"}] + args: ["Init", "{localization}", { + lang: "default", + urlPathname: "{localization}.options.pathnames.original" + }] }, { func: "{localization}.applier.change", - args: ["value", "fr"] + args: ["lang", "en"] }, { changeEvent: "{localization}.applier.modelChanged", - spec: {path: "value", priority: "last:testing"}, + spec: {path: "lang", priority: "last:testing"}, listener: "fluid.tests.localizationTester.assertLocale", - args: ["{localization}", {value: "fr"}] + // The setPathname function isn't called because the URL hasn't changed. That is why the + // expectedPathname is the same as before. + args: ["English", "{localization}", { + lang: "en", + urlPathname: "{localization}.options.pathnames.english" + }] }, { func: "{localization}.applier.change", - args: ["value", "es"] + args: ["lang", "fr"] }, { - event: "{localization}.events.onLocalizationChangeRequested", - listener: "jqUnit.assertEquals", - args: ["Event arguments are as expected", "es", "{arguments}.0"] + changeEvent: "{localization}.applier.modelChanged", + spec: {path: "lang", priority: "last:testing"}, + listener: "fluid.tests.localizationTester.assertLocale", + args: ["French", "{localization}", { + lang: "fr", + urlPathname: "{localization}.options.pathnames.french" + }, "{localization}.options.pathnames.french"] }, { - funcName: "fluid.tests.localizationTester.assertLocale", - args: ["{localization}", {value: "es"}] + func: "{localization}.applier.change", + args: ["lang", "default"] }, { - funcName: "fluid.tests.localizationTester.reset", - args: ["{localization}"] + changeEvent: "{localization}.applier.modelChanged", + spec: {path: "lang", priority: "last:testing"}, + listener: "fluid.tests.localizationTester.assertLocale", + args: ["Set to Default", "{localization}", { + lang: "default", + urlPathname: "{localization}.options.pathnames.french" + }] }, { - func: "fluid.tests.localizationTester.assertLocale", - args: ["{localization}", {value: ""}] + func: "{localization}.applier.change", + args: ["lang", "en"] + }, + { + changeEvent: "{localization}.applier.modelChanged", + spec: {path: "lang", priority: "last:testing"}, + listener: "fluid.tests.localizationTester.assertLocale", + args: ["Set back to English", "{localization}", { + lang: "en", + urlPathname: "{localization}.options.pathnames.english" + }, "{localization}.options.pathnames.english"] + }, + { + func: "{localization}.applier.change", + args: ["lang", "es"] + }, + { + changeEvent: "{localization}.applier.modelChanged", + spec: {path: "lang", priority: "last:testing"}, + listener: "fluid.tests.localizationTester.assertLocale", + args: ["Unsupported Language", "{localization}", { + lang: "es", + urlPathname: "{localization}.options.pathnames.english" + }] }] }] }] }); - fluid.tests.localizationTester.assertLocale = function (that, expectedModel) { - jqUnit.assertDeepEq("The model value is set correctly: " + expectedModel.value, expectedModel, that.model); + fluid.tests.localizationTester.assertLocale = function (prefix, that, expectedModel, setPathname) { + jqUnit.assertDeepEq(prefix + ": The model property is set correctly: " + expectedModel.lang, expectedModel, that.model); + var message = setPathname ? ": The correct URL pathname is set" : ": The pathname is not set."; + jqUnit.assertEquals(prefix + message, setPathname, that.options.recordedPathname); + //reset recordedPathname + that.options.recordedPathname = undefined; }; + /********************************************************************************* + *Tests for referencing a global fluid.prefs.enactor.localization via model relay + ********************************************************************************/ + fluid.defaults("fluid.tests.localizationExistingTests", { gradeNames: ["fluid.test.testEnvironment"], + events: { + onLocalizationReady: null + }, components: { - localization: { - type: "fluid.tests.prefs.enactor.localizationEnactor", - container: ".flc-localization-existing", - createOnEvent: "{localizationTester}.events.onTestCaseStart" + testComponent: { + type: "fluid.modelComponent", + createOnEvent: "onLocalizationReady", + options: { + model: { + lang: "{localization}.model.lang" + } + } }, - localizationTester: { + tester: { type: "fluid.tests.localizationExistingTester" } } }); + fluid.tests.localizationExistingTests.initLocalization = function (that) { + that.localization = fluid.prefs.enactor.localization(); + that.events.onDestroy.addListener(that.localization.destroy, "destroyLocalization"); + that.events.onLocalizationReady.fire(); + }; + fluid.defaults("fluid.tests.localizationExistingTester", { gradeNames: ["fluid.test.testCaseHolder"], modules: [{ - name: "fluid.prefs.enactor.localization", + name: "Global Localization", tests: [{ - expect: 5, - name: "Set localization when existing localization present", + expect: 1, + name: "Model Relay", sequence: [{ - listener: "jqUnit.assert", - event: "{localizationExistingTests localization}.events.onCreate", - args: ["The localization enactor was created"] - }, - { - func: "fluid.tests.localizationTester.assertLocale", - args: ["{localization}", {value: "en"}] - }, - { - func: "{localization}.applier.change", - args: ["value", "fr"] - }, - { - changeEvent: "{localization}.applier.modelChanged", - spec: {path: "value", priority: "last:testing"}, - func: "fluid.tests.localizationTester.assertLocale", - args: ["{localization}", {value: "fr"}] - }, - { - func: "{localization}.applier.change", - args: ["value", "es"] - }, - { - event: "{localization}.events.onLocalizationChangeRequested", - listener: "jqUnit.assertEquals", - args: ["Event arguments are as expected", "es", "{arguments}.0"] - }, - { - funcName: "fluid.tests.localizationTester.assertLocale", - args: ["{localization}", {value: "es"}] + funcName: "fluid.tests.localizationExistingTests.initLocalization", + args: ["{localizationExistingTests}"] + }, { + func: "{localizationExistingTests}.localization.applier.change", + args: ["lang", "en"] + }, { + changeEvent: "{testComponent}.applier.modelChanged", + spec: {path: "lang", priority: "last:testing"}, + func: "jqUnit.assertDeepEq", + args: ["The model relay to the global localization component should have updated the test component's model", {lang: "en"}, "{testComponent}.model"] }] }] }] }); - fluid.tests.localizationTester.reset = function (that) { - that.model.value = ""; - }; - $(document).ready(function () { fluid.test.runTests([ "fluid.tests.localizationTests", diff --git a/tests/framework-tests/preferences/js/LocalizationPanelTests.js b/tests/framework-tests/preferences/js/LocalizationPanelTests.js index 001720da92..3dc03578fa 100644 --- a/tests/framework-tests/preferences/js/LocalizationPanelTests.js +++ b/tests/framework-tests/preferences/js/LocalizationPanelTests.js @@ -36,14 +36,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt template: { href: "../../../../src/framework/preferences/html/PrefsEditorTemplate-localization.html" } - }, - classnameMap: { - "localization": { - "en": "fl-localization-en", - "es": "fl-localization-es", - "fa": "fl-localization-fa", - "fr": "fl-localization-fr" - } } }); @@ -64,14 +56,14 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt fluid.defaults("fluid.tests.localizationTester", { gradeNames: ["fluid.test.testCaseHolder"], testOptions: { - expectedNumOfOptions: 4, + expectedNumOfOptions: 5, defaultValue: "en", newValue: "fr" }, modules: [{ name: "Test the localization settings panel", tests: [{ - expect: 9, + expect: 15, name: "Test the rendering of the localization panel", sequence: [{ event: "{fluid.tests.localizationPanelTests localization}.events.afterRender", @@ -94,19 +86,19 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt }); fluid.tests.localizationTester.testDefault = function (that, expectedNumOfOptions, expectedLocale) { - var options = that.container.find("option"); + var selectOptions = that.container.find("option"); var messageBase = that.options.messageBase; - jqUnit.assertEquals("There are " + expectedNumOfOptions + " locales in the control", expectedNumOfOptions, options.length); - jqUnit.assertEquals("The first locale is " + expectedLocale, expectedLocale, options.filter(":selected").val()); + jqUnit.assertEquals("There are " + expectedNumOfOptions + " locales in the control", expectedNumOfOptions, selectOptions.length); + selectOptions.each(function (index, elm) { + elm = $(elm); + jqUnit.assertEquals("The language option at index: " + index + " has the correct value", that.options.controlValues.localization[index], elm.val()); + var stringArrayIndex = that.options.stringArrayIndex.localization[index]; + jqUnit.assertEquals("The language option at index: " + index + " has the correct text", messageBase[stringArrayIndex], elm.text()); + }); + + jqUnit.assertEquals("The selected locale is " + expectedLocale, expectedLocale, selectOptions.filter(":selected").val()); jqUnit.assertEquals("The label text is " + messageBase.label, messageBase.label, that.locate("label").text()); jqUnit.assertEquals("The description text is " + messageBase.description, messageBase.description, that.locate("localizationDescr").text()); - - fluid.each(options, function (option) { - var css = that.options.classnameMap.localization[option.value]; - if (css) { - jqUnit.assertTrue("The option has appropriate css applied", $(option).hasClass(css)); - } - }); }; $(document).ready(function () { From 92c25251fbf3d837fce32a05d95905134964d2ac Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Thu, 20 Dec 2018 10:09:04 -0500 Subject: [PATCH 19/30] FLUID-6303: Moved example to a sub directory to make room for more. --- .../localizationPreference/fa/index.html | 105 ------------------ .../localizationPreference/fr/index.html | 105 ------------------ .../localizationPreference/index.html | 104 ----------------- .../urlPath/es/index.html | 105 ++++++++++++++++++ .../urlPath/fa/index.html | 105 ++++++++++++++++++ .../urlPath/fr/index.html | 105 ++++++++++++++++++ .../{ => urlPath}/html/prefsEditor.html | 0 .../{es => urlPath}/index.html | 11 +- .../{ => urlPath}/js/localization.js | 33 +++++- 9 files changed, 352 insertions(+), 321 deletions(-) delete mode 100644 examples/framework/preferences/localizationPreference/fa/index.html delete mode 100644 examples/framework/preferences/localizationPreference/fr/index.html delete mode 100644 examples/framework/preferences/localizationPreference/index.html create mode 100644 examples/framework/preferences/localizationPreference/urlPath/es/index.html create mode 100644 examples/framework/preferences/localizationPreference/urlPath/fa/index.html create mode 100644 examples/framework/preferences/localizationPreference/urlPath/fr/index.html rename examples/framework/preferences/localizationPreference/{ => urlPath}/html/prefsEditor.html (100%) rename examples/framework/preferences/localizationPreference/{es => urlPath}/index.html (96%) rename examples/framework/preferences/localizationPreference/{ => urlPath}/js/localization.js (59%) diff --git a/examples/framework/preferences/localizationPreference/fa/index.html b/examples/framework/preferences/localizationPreference/fa/index.html deleted file mode 100644 index 7927451187..0000000000 --- a/examples/framework/preferences/localizationPreference/fa/index.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - ویرایشگر ترجیحات: اولویت محلی سازی - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - -
        - - - - -
        - - -
        - - -
        - - - - -
        -
        - - -

        سلام دنیا!

        - - - - diff --git a/examples/framework/preferences/localizationPreference/fr/index.html b/examples/framework/preferences/localizationPreference/fr/index.html deleted file mode 100644 index 9fd5fdadf4..0000000000 --- a/examples/framework/preferences/localizationPreference/fr/index.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - Editeur de préférences: Préférence de localisation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - -
        - - - - -
        - - -
        - - -
        - - - - -
        -
        - - -

        Bonjour le monde!

        - - - - diff --git a/examples/framework/preferences/localizationPreference/index.html b/examples/framework/preferences/localizationPreference/index.html deleted file mode 100644 index 4c962a13e7..0000000000 --- a/examples/framework/preferences/localizationPreference/index.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - Preferences Editor: Localization Preference - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - -
        - - - - -
        - - -
        - - -
        - - - - -
        -
        - - -

        Hello World!

        - - - - diff --git a/examples/framework/preferences/localizationPreference/urlPath/es/index.html b/examples/framework/preferences/localizationPreference/urlPath/es/index.html new file mode 100644 index 0000000000..9f802ed929 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/urlPath/es/index.html @@ -0,0 +1,105 @@ + + + + + + + + + + + + + Editor de preferencias: Preferencia de localización + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        + +
        + + + + +
        + + +
        + + +
        + + + + +
        +
        + + +

        Hola Mundo!

        + + + + diff --git a/examples/framework/preferences/localizationPreference/urlPath/fa/index.html b/examples/framework/preferences/localizationPreference/urlPath/fa/index.html new file mode 100644 index 0000000000..402356b948 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/urlPath/fa/index.html @@ -0,0 +1,105 @@ + + + + + + + + + + + + + ویرایشگر ترجیحات: اولویت محلی سازی + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        + +
        + + + + +
        + + +
        + + +
        + + + + +
        +
        + + +

        سلام دنیا!

        + + + + diff --git a/examples/framework/preferences/localizationPreference/urlPath/fr/index.html b/examples/framework/preferences/localizationPreference/urlPath/fr/index.html new file mode 100644 index 0000000000..1780c6f8a0 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/urlPath/fr/index.html @@ -0,0 +1,105 @@ + + + + + + + + + + + + + Editeur de préférences: Préférence de localisation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        + +
        + + + + +
        + + +
        + + +
        + + + + +
        +
        + + +

        Bonjour le monde!

        + + + + diff --git a/examples/framework/preferences/localizationPreference/html/prefsEditor.html b/examples/framework/preferences/localizationPreference/urlPath/html/prefsEditor.html similarity index 100% rename from examples/framework/preferences/localizationPreference/html/prefsEditor.html rename to examples/framework/preferences/localizationPreference/urlPath/html/prefsEditor.html diff --git a/examples/framework/preferences/localizationPreference/es/index.html b/examples/framework/preferences/localizationPreference/urlPath/index.html similarity index 96% rename from examples/framework/preferences/localizationPreference/es/index.html rename to examples/framework/preferences/localizationPreference/urlPath/index.html index 77edadabf9..921ff28ad2 100644 --- a/examples/framework/preferences/localizationPreference/es/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/index.html @@ -1,5 +1,5 @@ - + @@ -10,7 +10,7 @@ - Editor de preferencias: Preferencia de localización + Preferences Editor: Localization Preference @@ -55,7 +55,7 @@ - + @@ -89,7 +89,7 @@ -

        Hola Mundo!

        +

        Hello World!

        diff --git a/examples/framework/preferences/localizationPreference/js/localization.js b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js similarity index 59% rename from examples/framework/preferences/localizationPreference/js/localization.js rename to examples/framework/preferences/localizationPreference/urlPath/js/localization.js index aa06994b06..76d1a8a4e2 100644 --- a/examples/framework/preferences/localizationPreference/js/localization.js +++ b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js @@ -34,7 +34,12 @@ var example = example || {}; "fa": "fa", "fr": "fr" }, - langSegIndex: 6 + langSegIndex: { + expander: { + funcName: "example.prefsEditor.getLangSegIndex", + args: ["{example.prefsEditor}.options.localizationOpts.enactor.langMap"] + } + } }, panel: { controlValues: { @@ -62,4 +67,30 @@ var example = example || {}; } }); + /** + * Used as an expander to find the langSegIndex. For most implementations this would actually refer to 1, which + * is the default value; meaning a scheme such as this would not be required. However, the way this example is + * constructed and expected to run, the langSegIndex is at the end of the path. Because we don't know ahead of time + * where how the example will be served, we don't know the full path and must dynamically calculate the index. + * + * @param {Object} langMap - a mapping of language code to URL path resource. + * + * @return {Integer} - The lagSegIndex. Defaults to 1 if none of the values from the langMap are found in the + * current location pathname. + */ + example.prefsEditor.getLangSegIndex = function (langMap) { + var langVals = fluid.values(langMap); + var pathSegs = location.pathname.split("/"); + var index = "1"; + + fluid.each(langVals, function (langVal) { + var foundIndex = pathSegs.lastIndexOf(langVal); + if (foundIndex >= 0) { + index = foundIndex; + } + }); + + return index; + }; + })(jQuery, fluid); From 66a61cda45bf23180bde68abd2365848ae4931eb Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Thu, 20 Dec 2018 12:53:02 -0500 Subject: [PATCH 20/30] FLUID-6303: Removing localizated UIO demo. Should add an example of dynamically localizing after FLUID-6300 is complete. --- .../html/SeparatedPanelPrefsEditor.html | 13 - demos/uiOptionsLocalized/index.html | 271 ------------------ demos/uiOptionsLocalized/js/uioDemo.js | 58 ---- 3 files changed, 342 deletions(-) delete mode 100644 demos/uiOptionsLocalized/html/SeparatedPanelPrefsEditor.html delete mode 100644 demos/uiOptionsLocalized/index.html delete mode 100644 demos/uiOptionsLocalized/js/uioDemo.js diff --git a/demos/uiOptionsLocalized/html/SeparatedPanelPrefsEditor.html b/demos/uiOptionsLocalized/html/SeparatedPanelPrefsEditor.html deleted file mode 100644 index 5a0a800c18..0000000000 --- a/demos/uiOptionsLocalized/html/SeparatedPanelPrefsEditor.html +++ /dev/null @@ -1,13 +0,0 @@ -
        -
        -
          -
        • -
        • -
        • -
        • -
        • -
        • -
        • -
        -
        -
        diff --git a/demos/uiOptionsLocalized/index.html b/demos/uiOptionsLocalized/index.html deleted file mode 100644 index 7f2764ee01..0000000000 --- a/demos/uiOptionsLocalized/index.html +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - - - - - - - - - - Preferences Editor Localized Demo: Using Schemas - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - -
        - -
        - - - - -
        - - -
        - - -
        - - - - -
        -
        - - - - -
        -
        - - -
        -
        - -
        -

        Preferences Editor

        -
        This page might be a bit difficult to read or use.
        - Why don't you consider using the display preferences option?
        -
        -
        -

        Some helpful tips

        -
          -
        1. Preference Editor and its different configurations.
          - On this page, Preference Editor can be found along the top edge. - There are other layout options in development - see Preference Editor Design Wireframes.
        2. -
        3. Try tinkering with the options.
        4. -
        -
        -
        -
        -

        Introduction

        - an orange -

        - Aliquam varius lacus non arcu venenatis scelerisque quis in sapien. - Curabitur nec felis tortor. - Cras euismod ipsum erat. - Sed ac lacus dolor, sed vestibulum sem. - Donec tristique lacinia augue. - In mollis venenatis mollis. - Duis facilisis fermentum accumsan. - Quisque aliquet eros at nunc volutpat euismod. -

        -

        - Pellentesque dictum mattis sapien a consectetur. - In hac habitasse platea dictumst. - Integer pharetra accumsan euismod. - Morbi congue leo eu diam bibendum luctus. - Ut quam orci, rhoncus sed fermentum eget, tempus rhoncus justo. - Donec gravida lorem vel orci aliquam vitae tristique ipsum pulvinar. - Sed lorem orci, gravida ac tristique at, aliquam eget massa. -

        -

        - In diam lorem, consequat vel lobortis non, pretium in leo. - Cras ut dolor ac nunc pharetra venenatis id at orci. - Nam a nibh id lectus dignissim molestie. - Donec est arcu, luctus eu tempor quis, posuere non risus. -

        -

        Why do oranges taste better than apples?

        -

        - Aliquam mattis placerat odio. - Aliquam sodales euismod sodales. - Integer mollis nulla eget quam imperdiet vitae elementum sapien adipiscing. -

        -
        -
        -

        - Sed tempus laoreet facilisis. - Curabitur at augue in justo tincidunt cursus. - Aliquam iaculis libero vel dolor fringilla a rutrum nisl tempus. -

        -

        - Cras lorem nulla, tincidunt nec dapibus id, interdum pellentesque elit. - Sed faucibus posuere augue, ac vehicula dolor feugiat id. - Ut scelerisque mollis aliquam. - Nulla facilisi. - Vestibulum porttitor pulvinar mauris et placerat. - Donec ultrices, eros eget pharetra eleifend, risus orci iaculis leo, nec facilisis nisi odio et nunc. -

        -

        - Sed varius sem sed sapien cursus vel iaculis nisl rhoncus. - Fusce placerat sapien ut erat mollis vestibulum. - Aenean eget tellus sem. -

        - -

        Some people actually prefer apples

        - an apple -

        - Praesent vulputate, sem vel feugiat iaculis, eros diam condimentum nisl, eget suscipit nunc est vitae justo. - Vivamus imperdiet convallis laoreet. - Quisque eget magna vitae tortor egestas imperdiet. -

        -

        - Donec at ipsum magna. - Suspendisse potenti. - Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. - Mauris vel eros eu purus sodales rutrum. - Suspendisse potenti. -

        - -
        -
        -

        - Fusce vel massa vitae dui sollicitudin adipiscing eget sed velit. - Fusce auctor vehicula turpis non faucibus. - Sed faucibus mollis enim venenatis mollis. - Morbi cursus scelerisque ornare. - Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. - Cras at cursus nisl. -

        -

        Conclusion: Oranges are still yummier

        -

        - Praesent consequat laoreet tellus, quis molestie dui pretium sit amet. - Donec et turpis vitae tortor blandit tristique eu sed justo. - Fusce in quam sem, ac hendrerit nisl. - Mauris consequat tellus in est vehicula placerat. - Sed sed ornare quam. - Quisque vel faucibus augue. - Donec euismod tellus a risus fringilla congue. - Proin feugiat, mauris ut ullamcorper pharetra, sem nulla lacinia nunc, ut hendrerit justo urna malesuada libero. - Pellentesque viverra fringilla arcu, consectetur interdum sapien tempus sed. - Donec tincidunt consequat libero, quis vulputate magna ullamcorper. -

        -
        -
        -

        Leave some feedback

        - -
        -
        -
        - - diff --git a/demos/uiOptionsLocalized/js/uioDemo.js b/demos/uiOptionsLocalized/js/uioDemo.js deleted file mode 100644 index a66bca085d..0000000000 --- a/demos/uiOptionsLocalized/js/uioDemo.js +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2018 OCAD University - -Licensed under the Educational Community License (ECL), Version 2.0 or the New -BSD license. You may not use this file except in compliance with one these -Licenses. - -You may obtain a copy of the ECL 2.0 License and BSD License at -https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt -*/ - -var fluid_3_0_0 = fluid_3_0_0 || {}; -(function ($, fluid) { - "use strict"; - - fluid.prefs.builder({ - gradeNames: ["fluid.prefs.auxSchema.starter", "fluid.prefs.auxSchema.localization"], - auxiliarySchema: { - template: "html/SeparatedPanelPrefsEditor.html" - } - }); - - fluid.defaults("fluid.uiOptions.prefsEditor.localizedDemoControls", { - gradeNames: ["fluid.viewComponent"], - events: { - onLocaleChangeRequested: "{fluid.uiOptions.prefsEditor.localized}.events.onInterfaceLocaleChangeRequested" - }, - selectors: { - languageLinkEnglish: ".flc-languages-en", - languageLinkSpanish: ".flc-languages-es", - languageLinkFarsi: ".flc-languages-fa", - languageLinkFrench: ".flc-languages-fr" - }, - listeners: { - "onCreate.bindLanguageLinkEnglish": { - "this": "{that}.dom.languageLinkEnglish", - "method": "click", - "args": ["en", "{that}.events.onLocaleChangeRequested.fire"] - }, - "onCreate.bindLanguageLinkSpanish": { - "this": "{that}.dom.languageLinkSpanish", - "method": "click", - "args": ["es", "{that}.events.onLocaleChangeRequested.fire"] - }, - "onCreate.bindLanguageLinkFarsi": { - "this": "{that}.dom.languageLinkFarsi", - "method": "click", - "args": ["fa", "{that}.events.onLocaleChangeRequested.fire"] - }, - "onCreate.bindLanguageLinkFrench": { - "this": "{that}.dom.languageLinkFrench", - "method": "click", - "args": ["fr", "{that}.events.onLocaleChangeRequested.fire"] - } - } - }); - -})(jQuery, fluid_3_0_0); From 9b63817905dc816a83215e50eced7c795692ea47 Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Tue, 8 Jan 2019 12:38:29 -0500 Subject: [PATCH 21/30] FLUID-6303: Updating the farsi translation --- src/framework/preferences/messages/localization_fa.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/framework/preferences/messages/localization_fa.json b/src/framework/preferences/messages/localization_fa.json index ce5b5164a8..551dae9867 100644 --- a/src/framework/preferences/messages/localization_fa.json +++ b/src/framework/preferences/messages/localization_fa.json @@ -7,5 +7,5 @@ "localization-fa": "فارسی", "localization-fr": "Français", "label": "بومی سازی", - "description": "تغییر زبان و / یا زبان" + "description": "تغییر گویش و / یا زبان" } From c9e7746783c8cbd4db52510c2c27aa42cf658bed Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Tue, 8 Jan 2019 15:16:45 -0500 Subject: [PATCH 22/30] FLUID-6303: Localizing templates used in the localization examples. --- .../localizationPreference/urlPath/es/index.html | 8 ++++---- .../localizationPreference/urlPath/fa/index.html | 8 ++++---- .../localizationPreference/urlPath/fr/index.html | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/framework/preferences/localizationPreference/urlPath/es/index.html b/examples/framework/preferences/localizationPreference/urlPath/es/index.html index 9f802ed929..2a36c63b0e 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/es/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/es/index.html @@ -68,8 +68,8 @@ -->
        - - + +
        @@ -82,8 +82,8 @@ -->
        - - + +
        diff --git a/examples/framework/preferences/localizationPreference/urlPath/fa/index.html b/examples/framework/preferences/localizationPreference/urlPath/fa/index.html index 402356b948..54fdbd542e 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/fa/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/fa/index.html @@ -68,8 +68,8 @@ -->
        - - + +
        @@ -82,8 +82,8 @@ -->
        - - + +
        diff --git a/examples/framework/preferences/localizationPreference/urlPath/fr/index.html b/examples/framework/preferences/localizationPreference/urlPath/fr/index.html index 1780c6f8a0..6faa447ade 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/fr/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/fr/index.html @@ -68,8 +68,8 @@ -->
        - - + +
        @@ -82,8 +82,8 @@ -->
        - - + +
        From 1c9cad86a5920c7d13f09c97890484b45904d601 Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Thu, 10 Jan 2019 09:25:39 -0500 Subject: [PATCH 23/30] FLUID-6303: updated Farsi translations --- .../localizationPreference/urlPath/fa/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/framework/preferences/localizationPreference/urlPath/fa/index.html b/examples/framework/preferences/localizationPreference/urlPath/fa/index.html index 54fdbd542e..4e61288c5b 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/fa/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/fa/index.html @@ -68,8 +68,8 @@ -->
        - - + +
        @@ -82,8 +82,8 @@ -->
        - - + +
        From eb0863ec7f7e84a1172c057786983e23ad031e1d Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Mon, 14 Jan 2019 11:00:22 -0500 Subject: [PATCH 24/30] FLUID-6303: Addressing code review comments. Largely around refactoring the example to make it easier to work with. This led to many refactorings in the implementation for the enactor and moving configuration for the constructed prefs editor into a shareable grade. --- .../urlPath/es/index.html | 21 ++- .../urlPath/fa/index.html | 21 ++- .../urlPath/fr/index.html | 21 ++- .../localizationPreference/urlPath/index.html | 20 ++- .../urlPath/js/localization.js | 78 +++------- .../preferences/js/LocalizationEnactor.js | 32 ++-- .../preferences/js/LocalizationPrefsEditor.js | 67 +++++++++ .../preferences/preferencesDependencies.json | 1 + tests/all-tests.html | 5 +- .../preferences/all-tests.html | 11 +- .../LocalizationPrefsEditor-template.html | 7 + .../html/LocalizationPrefsEditor-test.html | 98 ++++++++++++ .../js/LocalizationEnactorTests.js | 22 +-- .../js/LocalizationPrefsEditorTests.js | 141 ++++++++++++++++++ 14 files changed, 438 insertions(+), 107 deletions(-) create mode 100644 src/framework/preferences/js/LocalizationPrefsEditor.js create mode 100644 tests/framework-tests/preferences/html/LocalizationPrefsEditor-template.html create mode 100644 tests/framework-tests/preferences/html/LocalizationPrefsEditor-test.html create mode 100644 tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js diff --git a/examples/framework/preferences/localizationPreference/urlPath/es/index.html b/examples/framework/preferences/localizationPreference/urlPath/es/index.html index 2a36c63b0e..3a9771f5ae 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/es/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/es/index.html @@ -54,6 +54,7 @@ + @@ -92,13 +93,21 @@

        Hola Mundo!

        diff --git a/examples/framework/preferences/localizationPreference/urlPath/fa/index.html b/examples/framework/preferences/localizationPreference/urlPath/fa/index.html index 4e61288c5b..2883803f13 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/fa/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/fa/index.html @@ -54,6 +54,7 @@ + @@ -92,13 +93,21 @@

        سلام دنیا!

        diff --git a/examples/framework/preferences/localizationPreference/urlPath/fr/index.html b/examples/framework/preferences/localizationPreference/urlPath/fr/index.html index 6faa447ade..699adaf36b 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/fr/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/fr/index.html @@ -54,6 +54,7 @@ + @@ -92,13 +93,21 @@

        Bonjour le monde!

        diff --git a/examples/framework/preferences/localizationPreference/urlPath/index.html b/examples/framework/preferences/localizationPreference/urlPath/index.html index 921ff28ad2..51295b9f00 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/index.html @@ -54,6 +54,7 @@ + @@ -92,12 +93,21 @@

        Hello World!

        diff --git a/examples/framework/preferences/localizationPreference/urlPath/js/localization.js b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js index 76d1a8a4e2..255db036b2 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/js/localization.js +++ b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js @@ -1,5 +1,5 @@ /* -Copyright 2018 OCAD University +Copyright 2018-2019 OCAD University Licensed under the Educational Community License (ECL), Version 2.0 or the New BSD license. You may not use this file except in compliance with one these @@ -15,70 +15,38 @@ var example = example || {}; (function ($, fluid) { "use strict"; - fluid.prefs.builder({ - gradeNames: ["fluid.prefs.auxSchema.localization"], - auxiliarySchema: { - "namespace": "example.prefs.localization" - } - }); - - fluid.defaults("example.prefsEditor", { - gradeNames: ["example.prefs.localization.prefsEditor"], - localizationOpts: { - enactor: { - localizationScheme: "urlPath", - langMap: { - "default": null, - "en": "", - "es": "es", - "fa": "fa", - "fr": "fr" - }, - langSegIndex: { - expander: { - funcName: "example.prefsEditor.getLangSegIndex", - args: ["{example.prefsEditor}.options.localizationOpts.enactor.langMap"] - } - } - }, - panel: { - controlValues: { - localization: ["default", "en", "fr", "es", "fa"] - } - } + fluid.defaults("example.prefs.localization", { + gradeNames: ["fluid.prefs.constructed.localizationConfig"], + localizationScheme: "urlPath", + locales: ["default", "en", "fr", "es", "fa"], + langMap: { + "default": null, + "en": "", + "es": "es", + "fa": "fa", + "fr": "fr" }, - distributeOptions: { - "example.localization.defaultLocale": { - source: "{that}.options.defaultLocale", - target: "{that prefsEditorLoader}.options.defaultLocale" - }, - "example.localization.localizationEnactor": { - source: "{that}.options.localizationOpts.enactor", - target: "{that uiEnhancer fluid.prefs.enactor.localization}.options" - }, - "example.localization.localizationPanel": { - source: "{that}.options.localizationOpts.panel", - target: "{that prefsEditor fluid.prefs.panel.localization}.options" - }, - "example.localization.template": { - source: "{that}.options.template", - target: "{that prefsEditorLoader > templateLoader}.options.resources.prefsEditor" + langSegIndex: { + expander: { + funcName: "example.prefs.localization.getLangSegIndex", + args: ["{that}.options.langMap"] } } }); /** - * Used as an expander to find the langSegIndex. For most implementations this would actually refer to 1, which - * is the default value; meaning a scheme such as this would not be required. However, the way this example is - * constructed and expected to run, the langSegIndex is at the end of the path. Because we don't know ahead of time - * where how the example will be served, we don't know the full path and must dynamically calculate the index. + * Used as an expander to find the `langSegIndex`. For most implementations this would actually refers to 1 and is + * the default `langSegIndex` set in the component's defaults. Meaning a scheme such as this would not be required. + * However, the way this example is constructed and expected to run, the `langSegIndex` is at the end of the path. + * Because we don't know ahead of time how this example will be served, we don't know the full path and must + * dynamically calculate the index. * * @param {Object} langMap - a mapping of language code to URL path resource. * - * @return {Integer} - The lagSegIndex. Defaults to 1 if none of the values from the langMap are found in the - * current location pathname. + * @return {Integer} - The `lagSegIndex`. Defaults to 1 if none of the values from the langMap are found in the + * current location's pathname. */ - example.prefsEditor.getLangSegIndex = function (langMap) { + example.prefs.localization.getLangSegIndex = function (langMap) { var langVals = fluid.values(langMap); var pathSegs = location.pathname.split("/"); var index = "1"; diff --git a/src/framework/preferences/js/LocalizationEnactor.js b/src/framework/preferences/js/LocalizationEnactor.js index 4d2db41702..d972d31faf 100644 --- a/src/framework/preferences/js/LocalizationEnactor.js +++ b/src/framework/preferences/js/LocalizationEnactor.js @@ -1,5 +1,5 @@ /* -Copyright 2018 OCAD University +Copyright 2018-2019 OCAD University Licensed under the Educational Community License (ECL), Version 2.0 or the New BSD license. You may not use this file except in compliance with one these @@ -43,8 +43,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; gradeNames: "fluid.prefs.enactor.localization.urlPathLocale", priority: "after:inPanel" } - }, - defaultGradeNames: "fluid.prefs.enactor.localization.no-op" + } } } }); @@ -67,7 +66,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; changePath: "urlPathname", value: { expander: { - func: "{that}.pathname" + func: "{that}.getPathname" } }, source: "initialURLPathname" @@ -80,29 +79,34 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; namespace: "langToURLPath" }, urlPathname: { - funcName: "{that}.pathname", + funcName: "{that}.setPathname", args: ["{change}.value"], excludeSource: ["init", "initialURLPathname"], namespace: "setURLPathname" } }, invokers: { - pathname: "fluid.prefs.enactor.localization.urlPathLocale.pathname" + getPathname: "fluid.prefs.enactor.localization.urlPathLocale.getPathname", + setPathname: "fluid.prefs.enactor.localization.urlPathLocale.setPathname" } }); /** - * A simple wrapper around the location.pathname setter/getter property. + * A simple wrapper around the location.pathname getter. * - * @param {String} pathname - (Optional) pathname to set. If not supplied the current pathname will be returned * @return {String} - If the `pathname` argument is not provided, the current pathname is returned */ - fluid.prefs.enactor.localization.urlPathLocale.pathname = function (pathname) { - if (fluid.isValue(pathname)) { - location.pathname = pathname; - } else { - return location.pathname; - } + fluid.prefs.enactor.localization.urlPathLocale.getPathname = function () { + return location.pathname; + }; + + /** + * A simple wrapper around the location.pathname setter. + * + * @param {String} pathname - The pathname to set. + */ + fluid.prefs.enactor.localization.urlPathLocale.setPathname = function (pathname) { + location.pathname = pathname; }; /** diff --git a/src/framework/preferences/js/LocalizationPrefsEditor.js b/src/framework/preferences/js/LocalizationPrefsEditor.js new file mode 100644 index 0000000000..e06153b3c9 --- /dev/null +++ b/src/framework/preferences/js/LocalizationPrefsEditor.js @@ -0,0 +1,67 @@ +/* +Copyright 2019 OCAD University + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt +*/ + +var fluid_3_0_0 = fluid_3_0_0 || {}; + +(function (fluid) { + "use strict"; + + /******************************************************************************* + * Starter auxiliary schema grade + * + * Contains the settings for the localization preference + *******************************************************************************/ + + // Fine-tune the starter aux schema and add localization preference + fluid.defaults("fluid.prefs.constructed.localizationConfig", { + gradeNames: ["fluid.contextAware"], + contextAwareness: { + localeChange: { + checks: { + urlPath: { + contextValue: "{localizationConfig}.options.localizationScheme", + equals: "urlPath", + gradeNames: "fluid.prefs.constructed.localizationConfig.urlPathLocale" + } + } + } + }, + distributeOptions: { + // When FLUID-6322 is complete, the default locale will be specifiable directly from the aux schema + "example.localization.defaultLocale": { + source: "{that}.options.defaultLocale", + target: "{that prefsEditorLoader}.options.defaultLocale" + }, + "example.localization.enactor.localizationScheme": { + source: "{that}.options.localizationScheme", + target: "{that uiEnhancer fluid.prefs.enactor.localization}.options.localizationScheme" + }, + "example.localization.panel.locales": { + source: "{that}.options.locales", + target: "{that prefsEditor fluid.prefs.panel.localization}.options.controlValues.localization" + } + } + }); + + fluid.defaults("fluid.prefs.constructed.localizationConfig.urlPathLocale", { + distributeOptions: { + "example.localization.enactor.langMap": { + source: "{that}.options.langMap", + target: "{that uiEnhancer fluid.prefs.enactor.localization}.options.langMap" + }, + "example.localization.enactor.langSegIndex": { + source: "{that}.options.langSegIndex", + target: "{that uiEnhancer fluid.prefs.enactor.localization}.options.langSegIndex" + } + } + }); + +})(fluid_3_0_0); diff --git a/src/framework/preferences/preferencesDependencies.json b/src/framework/preferences/preferencesDependencies.json index d24029defd..e2b7286c8f 100644 --- a/src/framework/preferences/preferencesDependencies.json +++ b/src/framework/preferences/preferencesDependencies.json @@ -43,6 +43,7 @@ "./js/SelfVoicingSchemas.js", "./js/SyllabificationSchemas.js", "./js/LocalizationSchemas.js", + "./js/LocalizationPrefsEditor.js", "./js/WordSpaceSchemas.js", "./js/Builder.js" ], diff --git a/tests/all-tests.html b/tests/all-tests.html index e8003d8a52..edcd160ffc 100644 --- a/tests/all-tests.html +++ b/tests/all-tests.html @@ -51,7 +51,6 @@ "/framework-tests/preferences/html/Enactors-test.html", "/framework-tests/preferences/html/FullNoPreviewPrefsEditor-test.html", "/framework-tests/preferences/html/FullPreviewPrefsEditor-test.html", - "/framework-tests/preferences/html/PageEnhancer-test.html", "/framework-tests/preferences/html/Panels-test.html", "/framework-tests/preferences/html/PrefsEditor-test.html", "/framework-tests/preferences/html/PrimaryBuilder-test.html", @@ -59,6 +58,8 @@ "/framework-tests/preferences/html/CaptionsPanel-test.html", "/framework-tests/preferences/html/LetterSpaceEnactor-test.html", "/framework-tests/preferences/html/LetterSpacePanel-test.html", + "/framework-tests/preferences/html/LocalizationEnactor-test.html", + "/framework-tests/preferences/html/LocalizationPanel-test.html", "/framework-tests/preferences/html/SelfVoicingEnactor-test.html", "/framework-tests/preferences/html/SyllabificationEnactor-test.html", "/framework-tests/preferences/html/SelfVoicingPanel-test.html", @@ -67,8 +68,10 @@ "/framework-tests/preferences/html/WordSpacePanel-test.html", "/framework-tests/preferences/html/SeparatedPanelPrefsEditor-test.html", "/framework-tests/preferences/html/SeparatedPanelPrefsEditorResponsive-test.html", + "/framework-tests/preferences/html/LocalizationPrefsEditor-test.html", "/framework-tests/preferences/html/Store-test.html", "/framework-tests/preferences/html/UIEnhancer-test.html", + "/framework-tests/preferences/html/PageEnhancer-test.html", "/framework-tests/preferences/html/URLUtilities-test.html", "/framework-tests/renderer/html/Renderer-test.html", "/framework-tests/renderer/html/RendererUtilities-test.html" diff --git a/tests/framework-tests/preferences/all-tests.html b/tests/framework-tests/preferences/all-tests.html index 26e9756bef..2eb2598c7c 100644 --- a/tests/framework-tests/preferences/all-tests.html +++ b/tests/framework-tests/preferences/all-tests.html @@ -21,11 +21,6 @@ "./html/SyllabificationEnactor-test.html", "./html/LocalizationEnactor-test.html", "./html/WordSpaceEnactor-test.html", - "./html/SeparatedPanelPrefsEditor-test.html", - "./html/SeparatedPanelPrefsEditorResponsive-test.html", - "./html/FullNoPreviewPrefsEditor-test.html", - "./html/FullPreviewPrefsEditor-test.html", - "./html/PageEnhancer-test.html", "./html/Panels-test.html", "./html/CaptionsPanel-test.html", "./html/LetterSpacePanel-test.html", @@ -36,7 +31,13 @@ "./html/PrimaryBuilder-test.html", "./html/Store-test.html", "./html/UIEnhancer-test.html", + "./html/PageEnhancer-test.html", "./html/PrefsEditor-test.html", + "./html/SeparatedPanelPrefsEditor-test.html", + "./html/SeparatedPanelPrefsEditorResponsive-test.html", + "./html/FullNoPreviewPrefsEditor-test.html", + "./html/FullPreviewPrefsEditor-test.html", + "./html/LocalizationPrefsEditor-test.html", "./html/URLUtilities-test.html" ]); diff --git a/tests/framework-tests/preferences/html/LocalizationPrefsEditor-template.html b/tests/framework-tests/preferences/html/LocalizationPrefsEditor-template.html new file mode 100644 index 0000000000..3151a4f650 --- /dev/null +++ b/tests/framework-tests/preferences/html/LocalizationPrefsEditor-template.html @@ -0,0 +1,7 @@ +
        +
        +
          +
        • +
        +
        +
        diff --git a/tests/framework-tests/preferences/html/LocalizationPrefsEditor-test.html b/tests/framework-tests/preferences/html/LocalizationPrefsEditor-test.html new file mode 100644 index 0000000000..e1e54ef875 --- /dev/null +++ b/tests/framework-tests/preferences/html/LocalizationPrefsEditor-test.html @@ -0,0 +1,98 @@ + + + + + Localization Prefs Editor Tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

        Localization Prefs Editor Test Suite

        +

        +
        +

        +
          + + +
          + +
          +
          + +
          + + +
          +
          + +
          +
          + +
          +

          Some Sample Title

          +

          Some content with a link and .

          +
          + +
          + + + diff --git a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js index 0a7ec14f24..ed674b5f85 100644 --- a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js @@ -1,5 +1,5 @@ /* -Copyright 2018 OCAD University +Copyright 2018-2019 OCAD University Licensed under the Educational Community License (ECL), Version 2.0 or the New BSD license. You may not use this file except in compliance with one these @@ -38,12 +38,12 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt langSegIndex: 1 }); - fluid.tests.prefs.enactor.localizationEnactor.pathname = function (that, pathname) { - if (fluid.isValue(pathname)) { - that.options.recordedPathname = pathname; - } else { - return that.options.recordedPathname || that.options.pathnames.original; - } + fluid.tests.prefs.enactor.localizationEnactor.getPathname = function (that) { + return that.options.recordedPathname || that.options.pathnames.original; + }; + + fluid.tests.prefs.enactor.localizationEnactor.setPathname = function (that, pathname) { + that.options.recordedPathname = pathname; }; fluid.defaults("fluid.tests.localizationTests", { @@ -54,8 +54,12 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt createOnEvent: "{localizationTester}.events.onTestCaseStart", options: { invokers: { - pathname: { - funcName: "fluid.tests.prefs.enactor.localizationEnactor.pathname", + getPathname: { + funcName: "fluid.tests.prefs.enactor.localizationEnactor.getPathname", + args: ["{that}"] + }, + setPathname: { + funcName: "fluid.tests.prefs.enactor.localizationEnactor.setPathname", args: ["{that}", "{arguments}.0"] } } diff --git a/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js b/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js new file mode 100644 index 0000000000..4bf30d2317 --- /dev/null +++ b/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js @@ -0,0 +1,141 @@ +/* +Copyright 2019 OCAD University + +Licensed under the Educational Community License (ECL), Version 2.0 or the New +BSD license. You may not use this file except in compliance with one these +Licenses. + +You may obtain a copy of the ECL 2.0 License and BSD License at +https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt +*/ + +/* global fluid */ + +(function ($) { + "use strict"; + + fluid.registerNamespace("fluid.tests"); + + + // Using the builder to create an instance of a prefs editor from the `fluid.prefs.auxSchema.localization` schema. + // The assembled grade is `fluid.tests.prefs.localization.prefsEditor`. + fluid.prefs.builder({ + gradeNames: ["fluid.prefs.auxSchema.localization"], + auxiliarySchema: { + "namespace": "fluid.tests.prefs.localization", + "terms": { + "templatePrefix": "../../../../src/framework/preferences/html", + "messagePrefix": "../../../../src/framework/preferences/messages" + }, + "template": "LocalizationPrefsEditor-template.html" + } + }); + + fluid.defaults("fluid.tests.localizationPrefsEditor", { + gradeNames: ["fluid.tests.prefs.localization.prefsEditor", "fluid.prefs.constructed.localizationConfig"], + localizationScheme: "urlPath", + locales: ["default", "en", "en-ca", "fr", "es", "fa"], + langMap: { + "default": null, + "en": "", + "en-ca": "en-Ca", + "es": "es", + "fa": "fa", + "fr": "fr" + }, + langSegIndex: 2, + defaultLocale: "fr" + }); + + fluid.defaults("fluid.tests.localizationPrefsEditorTests", { + gradeNames: ["fluid.test.testEnvironment"], + components: { + localizationPrefsEditor: { + type: "fluid.tests.localizationPrefsEditor", + container: ".flc-prefsEditor-separatedPanel", + createOnEvent: "{localizationPrefsEditorTester}.events.onTestCaseStart" + }, + localizationPrefsEditorTester: { + type: "fluid.tests.localizationPrefsEditorTester" + } + } + }); + + fluid.defaults("fluid.tests.localizationPrefsEditorTester", { + gradeNames: ["fluid.test.testCaseHolder"], + testOpts: { + localizationScheme: "urlPath", + locales: ["default", "en", "en-ca", "fr", "es", "fa"], + langMap: { + "default": null, + "en": "", + "en-ca": "en-Ca", + "es": "es", + "fa": "fa", + "fr": "fr" + }, + langSegIndex: 2, + defaultLocale: "fr" + }, + modules: [{ + name: "fluid.prefs.constructed.localizationConfig", + tests: [{ + expect: 6, + name: "Options Distributions", + sequence: [{ + // Init + listener: "jqUnit.assert", + event: "{localizationPrefsEditorTests localizationPrefsEditor}.events.onReady", + args: ["The prefs editor was created"] + }, { + // `defaultLocale` distributed to prefsEditorLoader + func: "jqUnit.assertEquals", + args: [ + "The defaultLocale is passed to the prefsEditorLoader", + "{that}.options.testOpts.defaultLocale", + "{localizationPrefsEditor}.prefsEditorLoader.options.defaultLocale" + ] + }, { + // `locales` distributed to localization panel + func: "jqUnit.assertDeepEq", + args: [ + "The localization panel's control values are set", + "{that}.options.testOpts.locales", + "{localizationPrefsEditor}.prefsEditorLoader.prefsEditor.fluid_prefs_panel_localization.options.controlValues.localization" + ] + }, { + // `localizationScheme` distributed to localization enactor + func: "jqUnit.assertEquals", + args: [ + "The localization enactor's localizationScheme is set", + "{that}.options.testOpts.localizationScheme", + "{localizationPrefsEditor}.enhancer.uiEnhancer.fluid_prefs_enactor_localization.options.localizationScheme" + ] + }, { + // `langMap` distributed to localization enactor + func: "jqUnit.assertDeepEq", + args: [ + "The localization enactor's langMap is set", + "{that}.options.testOpts.langMap", + "{localizationPrefsEditor}.enhancer.uiEnhancer.fluid_prefs_enactor_localization.options.langMap" + ] + }, { + // `langSegIndex` distributed to localization enactor + func: "jqUnit.assertEquals", + args: [ + "The localization enactor's langSegIndex is set", + "{that}.options.testOpts.langSegIndex", + "{localizationPrefsEditor}.enhancer.uiEnhancer.fluid_prefs_enactor_localization.options.langSegIndex" + ] + }] + }] + }] + }); + + $(document).ready(function () { + fluid.test.runTests([ + "fluid.tests.localizationPrefsEditorTests" + ]); + }); + +})(jQuery); From 8fdd1f7f45f98650505dc29ecbc266bf0f21646d Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Mon, 14 Jan 2019 12:08:31 -0500 Subject: [PATCH 25/30] FLUID-6303: Fixing up testem integration and updating Infusion dependencies. --- package.json | 20 +++++++++---------- .../html/LocalizationEnactor-test.html | 1 + .../html/LocalizationPanel-test.html | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 6e50d786ff..ba151b7f47 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "test:vagrant": "vagrant up && vagrant ssh -c 'cd /home/vagrant/sync/; DISPLAY=:0 npm test'", "test:vagrantBrowser": "vagrant up && vagrant ssh -c 'cd /home/vagrant/sync/; DISPLAY=:0 npm run test:browser'", "test:vagrantNode": "vagrant up && vagrant ssh -c 'cd /home/vagrant/sync/; DISPLAY=:0 npm run test:node'", - "posttest": "node node_modules/nyc/bin/nyc.js report -r text-summary -r html --report-dir reports --temp-directory coverage", + "posttest": "node node_modules/nyc/bin/nyc.js report -r text-summary -r html", "buildDists": "grunt buildDists", "buildStylus": "grunt buildStylus", "loadDependencies": "grunt loadDependencies" @@ -42,7 +42,7 @@ "devDependencies": { "eslint-config-fluid": "1.3.0", "gpii-grunt-lint-all": "1.0.5", - "gpii-testem": "2.1.5", + "gpii-testem": "2.1.7", "grunt": "1.0.2", "grunt-contrib-clean": "2.0.0", "grunt-contrib-compress": "1.4.3", @@ -52,7 +52,7 @@ "grunt-contrib-uglify": "4.0.0", "grunt-contrib-watch": "1.1.0", "grunt-modulefiles": "0.4.0", - "grunt-shell": "2.1.0", + "grunt-shell": "3.0.1", "hypher": "0.2.5", "@fluid-project/hyphenation-patterns": "0.2.2-dev.20181115T221631Z.b2d0651", "jquery": "3.3.1", @@ -63,13 +63,13 @@ "jquery.scrollto": "2.1.2", "lodash": "4.17.11", "ncp": "2.0.0", - "normalize.css": "8.0.0", - "nyc": "13.0.1", - "opensans-webkit": "1.0.1", - "rimraf": "2.6.2", + "normalize.css": "8.0.1", + "nyc": "13.1.0", + "opensans-webkit": "1.1.0", + "rimraf": "2.6.3", "roboto-fontface": "0.10.0", - "sinon": "6.3.3", - "testem": "2.9.3", - "url-polyfill": "1.1.0" + "sinon": "7.2.2", + "testem": "2.14.0", + "url-polyfill": "1.1.3" } } diff --git a/tests/framework-tests/preferences/html/LocalizationEnactor-test.html b/tests/framework-tests/preferences/html/LocalizationEnactor-test.html index 7fa553463b..5e4b2ebcfb 100644 --- a/tests/framework-tests/preferences/html/LocalizationEnactor-test.html +++ b/tests/framework-tests/preferences/html/LocalizationEnactor-test.html @@ -38,6 +38,7 @@ + diff --git a/tests/framework-tests/preferences/html/LocalizationPanel-test.html b/tests/framework-tests/preferences/html/LocalizationPanel-test.html index 16634a483a..454d10b5dc 100644 --- a/tests/framework-tests/preferences/html/LocalizationPanel-test.html +++ b/tests/framework-tests/preferences/html/LocalizationPanel-test.html @@ -39,6 +39,7 @@ + From 63e03e86aed15c148ffaa9bcbcea556f2e227a68 Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Mon, 14 Jan 2019 12:50:39 -0500 Subject: [PATCH 26/30] FLUID-6303: rolling back testem to v2.12.0 gpii-testem currently doesn't support beyond testem 2.12.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba151b7f47..f9f14f2e1b 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "rimraf": "2.6.3", "roboto-fontface": "0.10.0", "sinon": "7.2.2", - "testem": "2.14.0", + "testem": "2.12.0", "url-polyfill": "1.1.3" } } From 86b4685b998310d9b500a08ac221da3651326494 Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Wed, 16 Jan 2019 10:20:50 -0500 Subject: [PATCH 27/30] FLUID-6303: Corrected some errors with LocalizationPrefsEditor config. Including the addition of options distributions for the locale names to the stringArrayIndex to set the options for the panel. --- .../localizationPreference/urlPath/index.html | 3 +-- .../urlPath/js/localization.js | 3 ++- .../preferences/js/LocalizationPrefsEditor.js | 22 +++++++++++-------- .../js/LocalizationPrefsEditorTests.js | 16 +++++++++++--- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/examples/framework/preferences/localizationPreference/urlPath/index.html b/examples/framework/preferences/localizationPreference/urlPath/index.html index 51295b9f00..b85b307676 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/index.html +++ b/examples/framework/preferences/localizationPreference/urlPath/index.html @@ -105,8 +105,7 @@

          Hello World!

          } }, prefsEditor: { - gradeNames: ["example.prefs.localization"], - + gradeNames: ["example.prefs.localization"] } }); diff --git a/examples/framework/preferences/localizationPreference/urlPath/js/localization.js b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js index 255db036b2..ea793159da 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/js/localization.js +++ b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js @@ -16,8 +16,9 @@ var example = example || {}; "use strict"; fluid.defaults("example.prefs.localization", { - gradeNames: ["fluid.prefs.constructed.localizationConfig"], + gradeNames: ["fluid.prefs.constructed.localizationPrefsEditorConfig"], localizationScheme: "urlPath", + localeNames: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"], locales: ["default", "en", "fr", "es", "fa"], langMap: { "default": null, diff --git a/src/framework/preferences/js/LocalizationPrefsEditor.js b/src/framework/preferences/js/LocalizationPrefsEditor.js index e06153b3c9..52fb9b4a69 100644 --- a/src/framework/preferences/js/LocalizationPrefsEditor.js +++ b/src/framework/preferences/js/LocalizationPrefsEditor.js @@ -21,43 +21,47 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; *******************************************************************************/ // Fine-tune the starter aux schema and add localization preference - fluid.defaults("fluid.prefs.constructed.localizationConfig", { + fluid.defaults("fluid.prefs.constructed.localizationPrefsEditorConfig", { gradeNames: ["fluid.contextAware"], contextAwareness: { localeChange: { checks: { urlPath: { - contextValue: "{localizationConfig}.options.localizationScheme", + contextValue: "{localizationPrefsEditorConfig}.options.localizationScheme", equals: "urlPath", - gradeNames: "fluid.prefs.constructed.localizationConfig.urlPathLocale" + gradeNames: "fluid.prefs.constructed.localizationPrefsEditorConfig.urlPathLocale" } } } }, distributeOptions: { // When FLUID-6322 is complete, the default locale will be specifiable directly from the aux schema - "example.localization.defaultLocale": { + "prefsEditor.localization.defaultLocale": { source: "{that}.options.defaultLocale", target: "{that prefsEditorLoader}.options.defaultLocale" }, - "example.localization.enactor.localizationScheme": { + "prefsEditor.localization.enactor.localizationScheme": { source: "{that}.options.localizationScheme", target: "{that uiEnhancer fluid.prefs.enactor.localization}.options.localizationScheme" }, - "example.localization.panel.locales": { + "prefsEditor.localization.panel.locales": { source: "{that}.options.locales", target: "{that prefsEditor fluid.prefs.panel.localization}.options.controlValues.localization" + }, + "prefsEditor.localization.panel.localeNames": { + source: "{that}.options.localeNames", + target: "{that prefsEditor fluid.prefs.panel.localization}.options.stringArrayIndex.localization" } } }); - fluid.defaults("fluid.prefs.constructed.localizationConfig.urlPathLocale", { + fluid.defaults("fluid.prefs.constructed.localizationPrefsEditorConfig.urlPathLocale", { distributeOptions: { - "example.localization.enactor.langMap": { + "prefsEditor.localization.enactor.langMap": { source: "{that}.options.langMap", target: "{that uiEnhancer fluid.prefs.enactor.localization}.options.langMap" }, - "example.localization.enactor.langSegIndex": { + "prefsEditor.localization.enactor.langSegIndex": { source: "{that}.options.langSegIndex", target: "{that uiEnhancer fluid.prefs.enactor.localization}.options.langSegIndex" } diff --git a/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js b/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js index 4bf30d2317..9b0f11934a 100644 --- a/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js @@ -32,8 +32,9 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt }); fluid.defaults("fluid.tests.localizationPrefsEditor", { - gradeNames: ["fluid.tests.prefs.localization.prefsEditor", "fluid.prefs.constructed.localizationConfig"], + gradeNames: ["fluid.tests.prefs.localization.prefsEditor", "fluid.prefs.constructed.localizationPrefsEditorConfig"], localizationScheme: "urlPath", + localeNames: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"], locales: ["default", "en", "en-ca", "fr", "es", "fa"], langMap: { "default": null, @@ -65,6 +66,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt gradeNames: ["fluid.test.testCaseHolder"], testOpts: { localizationScheme: "urlPath", + localeNames: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"], locales: ["default", "en", "en-ca", "fr", "es", "fa"], langMap: { "default": null, @@ -78,9 +80,9 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt defaultLocale: "fr" }, modules: [{ - name: "fluid.prefs.constructed.localizationConfig", + name: "fluid.prefs.constructed.localizationPrefsEditorConfig", tests: [{ - expect: 6, + expect: 7, name: "Options Distributions", sequence: [{ // Init @@ -103,6 +105,14 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt "{that}.options.testOpts.locales", "{localizationPrefsEditor}.prefsEditorLoader.prefsEditor.fluid_prefs_panel_localization.options.controlValues.localization" ] + }, { + // `localeNames` distributed to localization panel + func: "jqUnit.assertDeepEq", + args: [ + "The localization panel's localization options have been set", + "{that}.options.testOpts.localeNames", + "{localizationPrefsEditor}.prefsEditorLoader.prefsEditor.fluid_prefs_panel_localization.options.stringArrayIndex.localization" + ] }, { // `localizationScheme` distributed to localization enactor func: "jqUnit.assertEquals", From 01a3878a87d38e8a4ad2b6786aa7be9db2b34110 Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Thu, 17 Jan 2019 13:26:52 -0500 Subject: [PATCH 28/30] FLUID-6303: Refactoring based on "design crit" feedback. Default is now called "No Preferences". Also refactored urlLangSeg into a model relay. --- .../urlPath/en/index.html | 114 ++++++++++++++++++ .../urlPath/js/localization.js | 13 +- .../preferences/js/LocalizationEnactor.js | 102 ++++++++-------- .../preferences/messages/localization_en.json | 2 +- .../messages/localization_en_CA.json | 2 +- .../messages/localization_en_US.json | 2 +- .../preferences/messages/localization_es.json | 2 +- .../preferences/messages/localization_fa.json | 2 +- .../preferences/messages/localization_fr.json | 2 +- .../js/LocalizationEnactorTests.js | 67 +++++----- .../js/LocalizationPrefsEditorTests.js | 2 - 11 files changed, 214 insertions(+), 96 deletions(-) create mode 100644 examples/framework/preferences/localizationPreference/urlPath/en/index.html diff --git a/examples/framework/preferences/localizationPreference/urlPath/en/index.html b/examples/framework/preferences/localizationPreference/urlPath/en/index.html new file mode 100644 index 0000000000..da00681a25 --- /dev/null +++ b/examples/framework/preferences/localizationPreference/urlPath/en/index.html @@ -0,0 +1,114 @@ + + + + + + + + + + + + + Preferences Editor: Localization Preference + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
          + +
          + + + + +
          + + +
          + + +
          + + + + +
          +
          + + +

          Hello World!

          + + + + diff --git a/examples/framework/preferences/localizationPreference/urlPath/js/localization.js b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js index ea793159da..6f6678f239 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/js/localization.js +++ b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js @@ -21,8 +21,7 @@ var example = example || {}; localeNames: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"], locales: ["default", "en", "fr", "es", "fa"], langMap: { - "default": null, - "en": "", + "en": "en", "es": "es", "fa": "fa", "fr": "fr" @@ -36,9 +35,9 @@ var example = example || {}; }); /** - * Used as an expander to find the `langSegIndex`. For most implementations this would actually refers to 1 and is + * Used as an expander to find the `langSegIndex`. For most implementations this would actually refer to 1; which is * the default `langSegIndex` set in the component's defaults. Meaning a scheme such as this would not be required. - * However, the way this example is constructed and expected to run, the `langSegIndex` is at the end of the path. + * However, the way this example is constructed, the `langSegIndex` is at the end of the path. * Because we don't know ahead of time how this example will be served, we don't know the full path and must * dynamically calculate the index. * @@ -50,9 +49,13 @@ var example = example || {}; example.prefs.localization.getLangSegIndex = function (langMap) { var langVals = fluid.values(langMap); var pathSegs = location.pathname.split("/"); - var index = "1"; + var index = 1; + + // Add an empty string to capture the case where no language has been set in the URL. + langVals.unshift(""); fluid.each(langVals, function (langVal) { + // we use `lastIndexOf` because we know the language code is set at the end of the URL in this example var foundIndex = pathSegs.lastIndexOf(langVal); if (foundIndex >= 0) { index = foundIndex; diff --git a/src/framework/preferences/js/LocalizationEnactor.js b/src/framework/preferences/js/LocalizationEnactor.js index d972d31faf..d200f01ebd 100644 --- a/src/framework/preferences/js/LocalizationEnactor.js +++ b/src/framework/preferences/js/LocalizationEnactor.js @@ -35,7 +35,10 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; localeChange: { checks: { inPanel: { - contextValue: "{iframeRenderer}" + contextValue: "{iframeRenderer}.id", + // The following undefined grade is needed to prevent the `urlPath` check from supplying its + // grade even when the `inPanel` check passes. + gradeNames: "fluid.prefs.enactor.localization.inPanel" }, urlPath: { contextValue: "{localization}.options.localizationScheme", @@ -57,35 +60,33 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; *******************************************************************************/ fluid.defaults("fluid.prefs.enactor.localization.urlPathLocale", { langMap: {}, // must be supplied by integrator - langSegIndex: 1, - model: { - urlPathname: undefined - }, - listeners: { - "onCreate.setURLPath": { - changePath: "urlPathname", - value: { - expander: { - func: "{that}.getPathname" - } - }, - source: "initialURLPathname" + langSegValues: { + expander: { + funcName: "fluid.values", + args: ["{that}.options.langMap"] } }, + // langSegIndex: 1, should be supplied by the integrator. Will default to 1 in `fluid.prefs.enactor.localization.urlPathLocale.updatePathname` + modelRelay: [{ + target: "urlLangSeg", + singleTransform: { + type: "fluid.transforms.valueMapper", + defaultInput: "{that}.model.lang", + match: "{that}.options.langMap" + } + }], modelListeners: { - lang: { - funcName: "fluid.prefs.enactor.localization.urlPathLocale.changeLocale", - args: ["{that}", "{change}.value", "{that}.options.langMap", "{that}.options.langSegIndex"], - namespace: "langToURLPath" - }, - urlPathname: { - funcName: "{that}.setPathname", + urlLangSeg: { + funcName: "{that}.updatePathname", args: ["{change}.value"], - excludeSource: ["init", "initialURLPathname"], - namespace: "setURLPathname" + namespace: "updateURLPathname" } }, invokers: { + updatePathname: { + funcName: "fluid.prefs.enactor.localization.urlPathLocale.updatePathname", + args: ["{that}", "{arguments}.0", "{that}.options.langSegValues", "{that}.options.langSegIndex"] + }, getPathname: "fluid.prefs.enactor.localization.urlPathLocale.getPathname", setPathname: "fluid.prefs.enactor.localization.urlPathLocale.setPathname" } @@ -115,42 +116,41 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; * to manually, navigate to a localized page when a language preference hasn't been set. * * @param {Component} that - an instance of `fluid.prefs.enactor.localization.urlPathLocale` - * @param {String} lang - a language code for the requested language - * @param {Object} langMap - a mapping of language code to URL path resource. This handles cases where the format - * is different, or if the primary language is served from the root. - * @param {Integer} langSegIndex - An optional index into the path where the language resource identifier is held. + * @param {String} urlLangSeg - a language value used in the URL pathname + * @param {Object} langSegValues - An array of the potential `urlLangSeg` values that can be set. + * @param {Integer} langSegIndex - (Optional) An index into the path where the language resource identifier is held. * By default this value is 1, which represents the first path segment. */ - fluid.prefs.enactor.localization.urlPathLocale.changeLocale = function (that, lang, langMap, langSegIndex) { + fluid.prefs.enactor.localization.urlPathLocale.updatePathname = function (that, urlLangSeg, langSegValues, langSegIndex) { - // Do nothing when the default language is chosen. - if (lang === "default") { - return; - } + if (fluid.isValue(urlLangSeg)) { + langSegIndex = langSegIndex || 1; + var pathname = that.getPathname(); + var pathSegs = pathname.split("/"); - langSegIndex = langSegIndex || 1; - var pathname = that.model.urlPathname; - var pathSegs = pathname.split("/"); - var currentLang = pathSegs[langSegIndex]; - var hasLang = currentLang && fluid.values(langMap).indexOf(currentLang) >= 0; - var newLangSeg = langMap[lang]; - - if (hasLang) { - if (newLangSeg) { - pathSegs[langSegIndex] = newLangSeg; - } else { - if (langSegIndex === pathSegs.length - 1) { - pathSegs[langSegIndex] = ""; + var currentLang = pathSegs[langSegIndex]; + var hasLang = !!currentLang && langSegValues.indexOf(currentLang) >= 0; + + if (hasLang) { + if (urlLangSeg) { + pathSegs[langSegIndex] = urlLangSeg; } else { - pathSegs.splice(langSegIndex, 1); + if (langSegIndex === pathSegs.length - 1) { + pathSegs.pop(); + } else { + pathSegs.splice(langSegIndex, 1); + } } + } else if (urlLangSeg) { + pathSegs.splice(langSegIndex, 0, urlLangSeg); } - } else if (newLangSeg) { - pathSegs.splice(langSegIndex, 0, newLangSeg); - } - var newPathname = pathSegs.join("/"); - that.applier.change("urlPathname", newPathname, "ADD", "changeLocale"); + var newPathname = pathSegs.join("/"); + + if (newPathname !== pathname) { + that.setPathname(newPathname); + } + } }; })(jQuery, fluid_3_0_0); diff --git a/src/framework/preferences/messages/localization_en.json b/src/framework/preferences/messages/localization_en.json index 6996c13604..5f096508f7 100644 --- a/src/framework/preferences/messages/localization_en.json +++ b/src/framework/preferences/messages/localization_en.json @@ -1,5 +1,5 @@ { - "localization-default": "Default", + "localization-default": "No Preference", "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", diff --git a/src/framework/preferences/messages/localization_en_CA.json b/src/framework/preferences/messages/localization_en_CA.json index 6996c13604..5f096508f7 100644 --- a/src/framework/preferences/messages/localization_en_CA.json +++ b/src/framework/preferences/messages/localization_en_CA.json @@ -1,5 +1,5 @@ { - "localization-default": "Default", + "localization-default": "No Preference", "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", diff --git a/src/framework/preferences/messages/localization_en_US.json b/src/framework/preferences/messages/localization_en_US.json index 6996c13604..5f096508f7 100644 --- a/src/framework/preferences/messages/localization_en_US.json +++ b/src/framework/preferences/messages/localization_en_US.json @@ -1,5 +1,5 @@ { - "localization-default": "Default", + "localization-default": "No Preference", "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", diff --git a/src/framework/preferences/messages/localization_es.json b/src/framework/preferences/messages/localization_es.json index 02e5accc18..51d4cae27d 100644 --- a/src/framework/preferences/messages/localization_es.json +++ b/src/framework/preferences/messages/localization_es.json @@ -1,5 +1,5 @@ { - "localization-default": "Defecto", + "localization-default": "Sin preferencias", "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", diff --git a/src/framework/preferences/messages/localization_fa.json b/src/framework/preferences/messages/localization_fa.json index 551dae9867..3b19f9896b 100644 --- a/src/framework/preferences/messages/localization_fa.json +++ b/src/framework/preferences/messages/localization_fa.json @@ -1,5 +1,5 @@ { - "localization-default": "پیش فرض", + "localization-default": "عدم ارجحیت", "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", diff --git a/src/framework/preferences/messages/localization_fr.json b/src/framework/preferences/messages/localization_fr.json index 22143a5ede..2834f4ac98 100644 --- a/src/framework/preferences/messages/localization_fr.json +++ b/src/framework/preferences/messages/localization_fr.json @@ -1,5 +1,5 @@ { - "localization-default": "Défault", + "localization-default": "Pas de préférence", "localization-en": "English", "localization-en_CA": "English (Canada)", "localization-en_US": "English (USA)", diff --git a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js index ed674b5f85..d6517880e8 100644 --- a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js @@ -27,19 +27,20 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt }, langMap: { en: "", - fr: "fr-ca" + "en-US": "en-US", + fr: "fr-CA" }, pathnames: { - original: "/about/", - english: "/about/", - french: "/fr-ca/about/" + default: "/about/", + english: "/about/en-US/", + french: "/about/fr-CA/" }, localizationScheme: "urlPath", - langSegIndex: 1 + langSegIndex: 2 }); fluid.tests.prefs.enactor.localizationEnactor.getPathname = function (that) { - return that.options.recordedPathname || that.options.pathnames.original; + return that.options.recordedPathname || that.options.pathnames["default"]; }; fluid.tests.prefs.enactor.localizationEnactor.setPathname = function (that, pathname) { @@ -76,7 +77,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt modules: [{ name: "fluid.prefs.enactor.localization", tests: [{ - expect: 13, + expect: 10, name: "Localization", sequence: [{ listener: "jqUnit.assert", @@ -86,26 +87,25 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt { func: "fluid.tests.localizationTester.assertLocale", args: ["Init", "{localization}", { - lang: "default", - urlPathname: "{localization}.options.pathnames.original" + lang: "default" }] }, { + // Change to en-US func: "{localization}.applier.change", - args: ["lang", "en"] + args: ["lang", "en-US"] }, { changeEvent: "{localization}.applier.modelChanged", spec: {path: "lang", priority: "last:testing"}, listener: "fluid.tests.localizationTester.assertLocale", - // The setPathname function isn't called because the URL hasn't changed. That is why the - // expectedPathname is the same as before. args: ["English", "{localization}", { - lang: "en", - urlPathname: "{localization}.options.pathnames.english" - }] + lang: "en-US", + urlLangSeg: "en-US" + }, "{localization}.options.pathnames.english"] }, { + // Change to fr func: "{localization}.applier.change", args: ["lang", "fr"] }, @@ -115,36 +115,39 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt listener: "fluid.tests.localizationTester.assertLocale", args: ["French", "{localization}", { lang: "fr", - urlPathname: "{localization}.options.pathnames.french" + urlLangSeg: "fr-CA" }, "{localization}.options.pathnames.french"] }, { + // Change to en func: "{localization}.applier.change", - args: ["lang", "default"] + args: ["lang", "en"] }, { changeEvent: "{localization}.applier.modelChanged", spec: {path: "lang", priority: "last:testing"}, listener: "fluid.tests.localizationTester.assertLocale", - args: ["Set to Default", "{localization}", { - lang: "default", - urlPathname: "{localization}.options.pathnames.french" - }] + args: ["English", "{localization}", { + lang: "en", + urlLangSeg: "" + }, "{localization}.options.pathnames.default"] }, { + // Change to default func: "{localization}.applier.change", - args: ["lang", "en"] + args: ["lang", "default"] }, { changeEvent: "{localization}.applier.modelChanged", spec: {path: "lang", priority: "last:testing"}, listener: "fluid.tests.localizationTester.assertLocale", - args: ["Set back to English", "{localization}", { - lang: "en", - urlPathname: "{localization}.options.pathnames.english" - }, "{localization}.options.pathnames.english"] + args: ["Set to Default", "{localization}", { + lang: "default", + urlLangSeg: "" + }] }, { + // Change to es func: "{localization}.applier.change", args: ["lang", "es"] }, @@ -154,19 +157,19 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt listener: "fluid.tests.localizationTester.assertLocale", args: ["Unsupported Language", "{localization}", { lang: "es", - urlPathname: "{localization}.options.pathnames.english" + urlLangSeg: "" }] }] }] }] }); - fluid.tests.localizationTester.assertLocale = function (prefix, that, expectedModel, setPathname) { + fluid.tests.localizationTester.assertLocale = function (prefix, that, expectedModel, pathname) { jqUnit.assertDeepEq(prefix + ": The model property is set correctly: " + expectedModel.lang, expectedModel, that.model); - var message = setPathname ? ": The correct URL pathname is set" : ": The pathname is not set."; - jqUnit.assertEquals(prefix + message, setPathname, that.options.recordedPathname); - //reset recordedPathname - that.options.recordedPathname = undefined; + + if (pathname) { + jqUnit.assertEquals(prefix + ": The correct URL pathname is set", pathname, that.options.recordedPathname); + } }; /********************************************************************************* diff --git a/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js b/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js index 9b0f11934a..15430456ca 100644 --- a/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js @@ -37,7 +37,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt localeNames: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"], locales: ["default", "en", "en-ca", "fr", "es", "fa"], langMap: { - "default": null, "en": "", "en-ca": "en-Ca", "es": "es", @@ -69,7 +68,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt localeNames: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"], locales: ["default", "en", "en-ca", "fr", "es", "fa"], langMap: { - "default": null, "en": "", "en-ca": "en-Ca", "es": "es", From 84820659081728094082cad95b3aff67bbbcdf32 Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Fri, 18 Jan 2019 13:38:28 -0500 Subject: [PATCH 29/30] FLUID-6303: added a comment and removed unused configuration. --- src/framework/preferences/js/LocalizationEnactor.js | 4 ++++ src/framework/preferences/js/LocalizationSchemas.js | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/framework/preferences/js/LocalizationEnactor.js b/src/framework/preferences/js/LocalizationEnactor.js index d200f01ebd..5ff4a4bac3 100644 --- a/src/framework/preferences/js/LocalizationEnactor.js +++ b/src/framework/preferences/js/LocalizationEnactor.js @@ -34,6 +34,10 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; contextAwareness: { localeChange: { checks: { + // This check determines if the enactor is being run inside of the separated panel's iframe. + // At the moment, all enactors are copied into the iframe to apply settings to the panel as well. + // However, the strings for the panel will be localized through the prefsEditorLoader and do not + // require the iframe URL to change. When in the panel, we do not run the urlPathLocale changes. inPanel: { contextValue: "{iframeRenderer}.id", // The following undefined grade is needed to prevent the `urlPath` check from supplying its diff --git a/src/framework/preferences/js/LocalizationSchemas.js b/src/framework/preferences/js/LocalizationSchemas.js index 86d0688e3b..0a78ade370 100644 --- a/src/framework/preferences/js/LocalizationSchemas.js +++ b/src/framework/preferences/js/LocalizationSchemas.js @@ -33,8 +33,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; localization: { "type": "fluid.prefs.localization", "enactor": { - "type": "fluid.prefs.enactor.localization", - "classes": "@localization.classes" + "type": "fluid.prefs.enactor.localization" }, "panel": { "type": "fluid.prefs.panel.localization", From e62fbd946a78d7bed7ee4cd54d07d593bc5a845c Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Sun, 20 Jan 2019 12:20:14 -0500 Subject: [PATCH 30/30] FLUID-6303: changing default lang to "" from "default" --- .../localizationPreference/urlPath/js/localization.js | 2 +- src/framework/preferences/js/LocalizationSchemas.js | 4 ++-- .../preferences/js/LocalizationEnactorTests.js | 4 ++-- .../preferences/js/LocalizationPrefsEditorTests.js | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/framework/preferences/localizationPreference/urlPath/js/localization.js b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js index 6f6678f239..ee811945b9 100644 --- a/examples/framework/preferences/localizationPreference/urlPath/js/localization.js +++ b/examples/framework/preferences/localizationPreference/urlPath/js/localization.js @@ -19,7 +19,7 @@ var example = example || {}; gradeNames: ["fluid.prefs.constructed.localizationPrefsEditorConfig"], localizationScheme: "urlPath", localeNames: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"], - locales: ["default", "en", "fr", "es", "fa"], + locales: ["", "en", "fr", "es", "fa"], langMap: { "en": "en", "es": "es", diff --git a/src/framework/preferences/js/LocalizationSchemas.js b/src/framework/preferences/js/LocalizationSchemas.js index 0a78ade370..ec356f489a 100644 --- a/src/framework/preferences/js/LocalizationSchemas.js +++ b/src/framework/preferences/js/LocalizationSchemas.js @@ -56,8 +56,8 @@ var fluid_3_0_0 = fluid_3_0_0 || {}; schema: { "fluid.prefs.localization": { "type": "string", - "default": "default", - "enum": ["default", "en", "en_CA", "en_US", "fr", "es", "fa"] + "default": "", + "enum": ["", "en", "en_CA", "en_US", "fr", "es", "fa"] } } }); diff --git a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js index d6517880e8..4e3b6b5619 100644 --- a/tests/framework-tests/preferences/js/LocalizationEnactorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationEnactorTests.js @@ -23,7 +23,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt fluid.defaults("fluid.tests.prefs.enactor.localizationEnactor", { gradeNames: ["fluid.prefs.enactor.localization"], model: { - lang: "default" + lang: "" }, langMap: { en: "", @@ -87,7 +87,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt { func: "fluid.tests.localizationTester.assertLocale", args: ["Init", "{localization}", { - lang: "default" + lang: "" }] }, { diff --git a/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js b/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js index 15430456ca..befbdcfc97 100644 --- a/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js +++ b/tests/framework-tests/preferences/js/LocalizationPrefsEditorTests.js @@ -35,7 +35,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt gradeNames: ["fluid.tests.prefs.localization.prefsEditor", "fluid.prefs.constructed.localizationPrefsEditorConfig"], localizationScheme: "urlPath", localeNames: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"], - locales: ["default", "en", "en-ca", "fr", "es", "fa"], + locales: ["", "en", "en-ca", "fr", "es", "fa"], langMap: { "en": "", "en-ca": "en-Ca", @@ -66,7 +66,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt testOpts: { localizationScheme: "urlPath", localeNames: ["localization-default", "localization-en", "localization-fr", "localization-es", "localization-fa"], - locales: ["default", "en", "en-ca", "fr", "es", "fa"], + locales: ["", "en", "en-ca", "fr", "es", "fa"], langMap: { "en": "", "en-ca": "en-Ca",