Skip to content
Permalink
Browse files

wip

  • Loading branch information
kacperj committed Sep 30, 2019
1 parent 90c653c commit 7c16be7595234c8d05df449a388791570bc41a62
@@ -1,9 +1,9 @@
import Validator = BookEngine.Forms.Validator;
import i18n = require("i18n");
import ko = require("knockout");
import _ = require("underscore");
import guidGenerator = require("../../src/guidGenerator");
import ErrorModel = BookEngine.Models.ErrorModel;
import { localize } from "../../localizations/en-US";
import guidGenerator = require("../../src/guidGenerator");

interface FieldValidation {
modelName: string;
@@ -167,7 +167,7 @@ class ValidationForm {
params = JSON.parse(JSON.stringify(modelStateError.additionalData));
}

const formatted = i18n.t(modelStateError.code, params);
const formatted = localize(modelStateError.code, params);

return formatted;
}
@@ -1,6 +1,7 @@
import i18n = require("i18n");

import MediumEditor = require("mediumeditor");
import _ = require("underscore");
import { localize } from "../../localizations/en-US";
import { SegmentModel, SegmentType } from "../../models/gamebook/segments/segmentModel";
import { createProcessor } from "../../src/editor/segments/segmentProcessorFactory";
import MicroVM = require("../base/microVM");
@@ -153,7 +154,7 @@ class EditorSegmentsVM extends MicroVM {
return {
imageDragging: false,
placeholder: {
text: i18n.t("editor.content.start_writing")
text: localize("editor.content.start_writing", {})
},
toolbar: {
buttons: [
@@ -1,4 +1,5 @@
import i18n = require("i18n");

import { localize } from "../../../localizations/en-US";
import { PageAnalyzeModel } from "../../../src/editor/analyzer/models/pageAnalyzeModel";
import { PageNavigationAnalyzeModel } from "../../../src/editor/analyzer/models/pageNavigationAnalyzeModel";
import { ProjectAnalyzeModel } from "../../../src/editor/analyzer/models/projectAnalyzeModel";
@@ -17,7 +18,7 @@ class GraphBuilder {
graphData.nodes.update({
id: "game-begin",
group: "gamebegin",
label: i18n.t("editor.architect.legend_elements.game_start"),
label: localize("editor.architect.legend_elements.game_start", {}),
radius: 20
});

@@ -64,7 +65,7 @@ class GraphBuilder {
let label = this.splitText(page.name);

if (pageAnalyzeModel.visibilityText !== null && pageAnalyzeModel.visibilityText !== "") {
label += "\n" + i18n.t("editor.architect.page_segments_variables") + "\n" + pageAnalyzeModel.visibilityText;
label += "\n" + localize("editor.architect.page_segments_variables", {}) + "\n" + pageAnalyzeModel.visibilityText;
}

const isEnding = navigationsFromPage.length === 0;
@@ -121,7 +122,7 @@ class GraphBuilder {

const variableInfoId = fromNode + "-action-condition-" + navigation.segmentId;

const label = i18n.t("editor.architect.navigation_conditions") + "\n" + navigation.actionCondition;
const label = localize("editor.architect.navigation_conditions", {}) + "\n" + navigation.actionCondition;

graphData.nodes.update({
id: variableInfoId,
@@ -144,7 +145,7 @@ class GraphBuilder {

const variableInfoId = fromNode + "-after-action-" + navigation.segmentId;

const label = i18n.t("editor.architect.actions") + "\n" + navigation.afterActionText;
const label = localize("editor.architect.actions", {}) + "\n" + navigation.afterActionText;

graphData.nodes.update({
id: variableInfoId,
@@ -1,4 +1,4 @@
import i18n = require("i18n");
import { localize } from "../../../localizations/en-US";
import { SegmentModel } from "../../../models/gamebook/segments/segmentModel";
import VariableType = require("../../../models/variables/variableType");
import parseExpression = require("../../../src/logicalExpressions/logicalExpressionParser");
@@ -51,10 +51,10 @@ class CommonEditorSegmentVM extends MicroVM {
this.OperatorList = this.ko.observableArray([
{
Value: "",
Caption: i18n.t("editor.variables_designer.values.true")
Caption: localize("editor.variables_designer.values.true", {})
}, {
Value: "!",
Caption: i18n.t("editor.variables_designer.values.false")
Caption: localize("editor.variables_designer.values.false", {})
}
]);

@@ -1,5 +1,5 @@
import i18n = require("i18n");
import confirmModalVM = require("../../../components/modals/confirmModalVM");
import { localize } from "../../../localizations/en-US";
import { NavigationSegmentModel } from "../../../models/gamebook/segments/segmentModel";
import VariableOperation = require("../../../models/variables/variableOperation");
import VariableType = require("../../../models/variables/variableType");
@@ -32,20 +32,20 @@ class NavigationEditorSegmentVM extends CommonEditorSegmentVM {
this.BoolValues = this.ko.observableArray([
{
val: "true",
text: i18n.t("editor.variables_designer.values.true")
text: localize("editor.variables_designer.values.true", {})
}, {
val: "false",
text: i18n.t("editor.variables_designer.values.false")
text: localize("editor.variables_designer.values.false", {})
}
]);

this.Operations = this.ko.observableArray([
{
val: VariableOperation.Assign,
text: i18n.t("editor.segment_settings.navigation.after_action_fields.action_set")
text: localize("editor.segment_settings.navigation.after_action_fields.action_set", {})
}, {
val: VariableOperation.Increment,
text: i18n.t("editor.segment_settings.navigation.after_action_fields.action_increment")
text: localize("editor.segment_settings.navigation.after_action_fields.action_increment", {})
}
]);

@@ -1,4 +1,5 @@
import i18n = require("i18n");

import { localize } from "../../localizations/en-US";
import { VariableModel } from "../../models/variables/variableModel";
import VariableType = require("../../models/variables/variableType");
import variableAnalyzer = require("../../src/editor/analyzer/variableAnalyzer");
@@ -79,19 +80,19 @@ class VariablesDesignerVM extends MicroVM {
this.BoolValues = this.ko.observableArray([
{
Value: true,
Caption: i18n.t("editor.variables_designer.values.true")
Caption: localize("editor.variables_designer.values.true", {})
}, {
Value: false,
Caption: i18n.t("editor.variables_designer.values.false")
Caption: localize("editor.variables_designer.values.false", {})
}
]);
this.VariableTypes = this.ko.observableArray([
{
Value: VariableType.Bool,
Caption: i18n.t("editor.variables_designer.types.boolean")
Caption: localize("editor.variables_designer.types.boolean", {})
}, {
Value: VariableType.Number,
Caption: i18n.t("editor.variables_designer.types.integer")
Caption: localize("editor.variables_designer.types.integer", {})
}
]);

@@ -114,19 +115,19 @@ class VariablesDesignerVM extends MicroVM {
this.BoolValues = this.ko.observableArray([
{
Value: true,
Caption: i18n.t("editor.variables_designer.values.true")
Caption: localize("editor.variables_designer.values.true", {})
}, {
Value: false,
Caption: i18n.t("editor.variables_designer.values.false")
Caption: localize("editor.variables_designer.values.false", {})
}
]);
this.VariableTypes = this.ko.observableArray([
{
Value: VariableType.Bool,
Caption: i18n.t("editor.variables_designer.types.boolean")
Caption: localize("editor.variables_designer.types.boolean", {})
}, {
Value: VariableType.Number,
Caption: i18n.t("editor.variables_designer.types.integer")
Caption: localize("editor.variables_designer.types.integer", {})
}
]);

@@ -281,7 +282,7 @@ class VariablesDesignerVM extends MicroVM {
private validateVariable(newVariableVM) {
if (newVariableVM.Name() === "") {
newVariableVM.IsValid(false);
newVariableVM.ValidationMessage(i18n.t("editor.variables_designer.validation.not_empty"));
newVariableVM.ValidationMessage(localize("editor.variables_designer.validation.not_empty", {}));
return;
}

@@ -293,25 +294,25 @@ class VariablesDesignerVM extends MicroVM {

if (hasSameName) {
newVariableVM.IsValid(false);
newVariableVM.ValidationMessage(i18n.t("editor.variables_designer.validation.already_defined"));
newVariableVM.ValidationMessage(localize("editor.variables_designer.validation.already_defined", {}));
return;
}

if (!/^[a-z]+/i.test(newVariableVM.Name())) {
newVariableVM.IsValid(false);
newVariableVM.ValidationMessage(i18n.t("editor.variables_designer.validation.start_with_letter"));
newVariableVM.ValidationMessage(localize("editor.variables_designer.validation.start_with_letter", {}));
return;
}

if (newVariableVM.Name().replace(/[^a-z0-9]/ig, "_") !== newVariableVM.Name()) {
newVariableVM.IsValid(false);
newVariableVM.ValidationMessage(i18n.t("editor.variables_designer.validation.only_alphanumeric"));
newVariableVM.ValidationMessage(localize("editor.variables_designer.validation.only_alphanumeric", {}));
return;
}

if (newVariableVM.Name().length > 18) {
newVariableVM.IsValid(false);
newVariableVM.ValidationMessage(i18n.t("editor.variables_designer.validation.too_long", { length: 18 }));
newVariableVM.ValidationMessage(localize("editor.variables_designer.validation.too_long", { length: 18 }));
return;
}

@@ -1,4 +1,4 @@
import i18n = require("i18n");
import { localize } from "../../../localizations/en-US";
import { GameBookStateModel } from "../../../models/state/gameBookStateModel";
import VariableType = require("../../../models/variables/variableType");
import gameBookProjectRepository = require("../../../src/repositories/gameBookProjectRepository");
@@ -35,10 +35,10 @@ class DebuggerVM extends MicroVM {
const boolValues = [
{
Value: true,
Caption: i18n.t("editor.variables_designer.values.true")
Caption: localize("editor.variables_designer.values.true", {})
}, {
Value: false,
Caption: i18n.t("editor.variables_designer.values.false")
Caption: localize("editor.variables_designer.values.false", {})
}
];

@@ -1,4 +1,4 @@
import i18n = require("i18n");
import { localize } from "../localizations/en-US";

class ErrorFormatter {
public errorMessageToList(errorObj: BookEngine.Models.ServiceErrorsModel): Array<string> {
@@ -32,13 +32,13 @@ class ErrorFormatter {
params = JSON.parse(JSON.stringify(modelStateError.additionalData));
}

const formatted = i18n.t(modelStateError.code, params);
const formatted = localize(modelStateError.code, params);

return formatted;
}

private getErrorFromCode(code): string {
return i18n.t(code);
return localize(code, {});
}
}

This file was deleted.

0 comments on commit 7c16be7

Please sign in to comment.
You can’t perform that action at this time.