[Ktutorial-commits] SF.net SVN: ktutorial:[325] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2011-06-13 19:49:27
|
Revision: 325 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=325&view=rev Author: danxuliu Date: 2011-06-13 19:49:21 +0000 (Mon, 13 Jun 2011) Log Message: ----------- Fix missed internationalization in options when exported to Javascript. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2011-06-12 15:29:27 UTC (rev 324) +++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2011-06-13 19:49:21 UTC (rev 325) @@ -226,19 +226,19 @@ if (reaction->triggerType() == Reaction::OptionSelected && reaction->responseType() == Reaction::NextStep) { - out() << "step.addOption(ktutorial.newOption(\"" - << escape(reaction->optionName()) << "\"), \"" + QString variable = writeOption(reaction->optionName()); + out() << "step.addOption(" << variable << ", \"" << escape(reaction->nextStepId()) << "\");\n"; return; } if (reaction->triggerType() == Reaction::OptionSelected && reaction->responseType() == Reaction::CustomCode) { + QString variable = writeOption(reaction->optionName()); QString functionName = toLowerCamelCase(step->id()) + "Step" + toUpperCamelCase(reaction->optionName()) + "OptionSelected"; - out() << "step.addOption(ktutorial.newOption(\"" - << escape(reaction->optionName()) << "\"), self, \"" + out() << "step.addOption(" << variable << ", self, \"" << functionName << "()\");\n"; addFunction(functionName, reaction->customCode()); return; @@ -262,6 +262,19 @@ addFunction(functionName, reaction->customCode()); } +QString JavascriptExporter::writeOption(const QString& optionName) { + Q_ASSERT(!optionName.isEmpty()); + + QString variable = toLowerCamelCase(optionName) + "Option"; + variable = addVariable(variable); + + out() << variable << " = ktutorial.newOption(t.i18nc(" + << "\"@action Tutorial option\", \"" << escape(optionName) + << "\"));\n"; + + return variable; +} + QString JavascriptExporter::writeWaitFor(const WaitFor* waitFor) { if (qobject_cast<const WaitForComposed*>(waitFor)) { return writeWaitFor(static_cast<const WaitForComposed*>(waitFor)); Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2011-06-12 15:29:27 UTC (rev 324) +++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2011-06-13 19:49:21 UTC (rev 325) @@ -170,6 +170,15 @@ void writeReaction(const Step* step, const Reaction* reaction); /** + * Writes the code to create and set an option. + * The option name can not be empty. + * + * @param optionName The name of the option. + * @return The name of the variable that holds the option. + */ + QString writeOption(const QString& optionName); + + /** * Writes the code to create and set a WaitFor. * * @param waitFor The WaitFor. Modified: trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp 2011-06-12 15:29:27 UTC (rev 324) +++ trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp 2011-06-13 19:49:21 UTC (rev 325) @@ -431,8 +431,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The option name\"), \ -\"Another step\");\n" +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, \"Another step\");\n" "\n" " The custom setup\n" " code\n" @@ -536,7 +537,9 @@ " step.addWaitFor(waitForTheSignalNameByTheEmitterName, self, \ \"theIdStepWaitForTheSignalNameByTheEmitterNameConditionMet()\");\n" "\n" -" step.addOption(ktutorial.newOption(\"The option name\"), self, \ +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, self, \ \"theIdStepTheOptionNameOptionSelected()\");\n" "}\n" CONNECT_STEP_SETUP @@ -575,8 +578,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The option name\"), \ -\"Another step\");\n" +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, \"Another step\");\n" "}\n" CONNECT_STEP_SETUP STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; @@ -604,8 +608,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The \\\"option\\\" name\"), \ -\"Another \\\"step\\\"\");\n" +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The \\\"option\\\" name\"));\n" +" step.addOption(theOptionNameOption, \"Another \\\"step\\\"\");\n" "}\n" CONNECT_STEP_SETUP STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; @@ -675,7 +680,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The option name\"), self, \ +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, self, \ \"theIdStepTheOptionNameOptionSelected()\");\n" "}\n" CONNECT_STEP_SETUP @@ -709,7 +716,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The \\\"option\\\" name\"), self, \ +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The \\\"option\\\" name\"));\n" +" step.addOption(theOptionNameOption, self, \ \"theIdStepTheOptionNameOptionSelected()\");\n" "}\n" CONNECT_STEP_SETUP @@ -757,7 +766,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The option name\"), self, \ +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, self, \ \"theIdStepTheOptionNameOptionSelected()\");\n" "}\n" CONNECT_STEP_SETUP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |