diff --git a/Gulpfile.coffee b/Gulpfile.coffee index 94096bd..ba1dea6 100644 --- a/Gulpfile.coffee +++ b/Gulpfile.coffee @@ -9,12 +9,14 @@ buffer = require('vinyl-buffer') zip = require('gulp-zip') concat = require('gulp-concat') rename = require('gulp-rename') +fs = require('fs') +CSON = require 'cson' reload = browserSync.reload html = (target) -> return () -> - gulp.src(['html/index.html']) + gulp.src(['html/index.html', 'html/en.html']) .pipe(gulp.dest(target)) gulp.src(['node_modules/salet/lib/index.min.js']) .pipe(rename('salet.min.js')) @@ -42,6 +44,11 @@ gulp.task('sass', () -> ) gulp.task('concatCoffee', () -> + for language in ['ru', 'en'] + data = CSON.parseCSONFile('game/translations/'+language+'.cson') + json = JSON.stringify(data) + '\n' + fs.writeFileSync("./build/game/translations/"+language+".json", json) + gulp.src([ ## additional functions './game/dialogue.coffee', diff --git a/game/begin.coffee b/game/begin.coffee index 4d85aab..80d02b1 100644 --- a/game/begin.coffee +++ b/game/begin.coffee @@ -1,7 +1,14 @@ -salet.game_id = "your-game-id-here" -salet.game_version = "1.6" +salet.game_id = "being-astrid-is-hard-enough-but-try-living-as-one" +salet.game_version = "1.0" ably = new Ably.Realtime('v6yAiA.PKvuDg:iJhwQu-DkAWpDOUB') -channel = ably.channels.get('astrid') +channel = ably.channels.get('astrid-'+i18n.lang) + +$.holdReady( true ) +$.getJSON('game/translations/'+i18n.lang+'.json', (data) -> + i18n.push(i18n.lang, data) + + $.holdReady( false ) +) $(document).ready(() -> window.addEventListener('popstate', (event) -> @@ -33,7 +40,7 @@ $(document).ready(() -> message.data.room == salet.current and message.data.name != salet.character.name ) - salet.view.write("В комнату входит "+message.data.name+".") + salet.view.write("room_enter".l()+message.data.name+".") ) salet.beginGame() @@ -55,14 +62,9 @@ actlink = (content, ref) -> # For accessibility reasons the text is provided in HTML, not here. room "start", enter: () -> - names = [ - 'рыжая Астрид', - 'Астрид-хулиганка', - 'волшебная русалка Астрид', - 'Астрид-ведьма' - ] + names = "names".l() salet.character.name = names[salet.rnd.randomInt(names.length)] - dsc: "" + dsc: () -> "intro".l() choices: "#start" croom = (name, options) -> @@ -72,5 +74,6 @@ croom = (name, options) -> room: @name, name: salet.character.name }) - options.dsc = "### #{options.title}\n" + options.dsc + options.dsc = () -> + "### #{@title()}\n" + @desc() return room(name,options) diff --git a/game/story.coffee b/game/story.coffee index 4dc5413..569bb0e 100644 --- a/game/story.coffee +++ b/game/story.coffee @@ -1,15 +1,11 @@ croom "entry", tags: ["start"], - optionText: "Быть Астрид" - title: "Прихожая" + optionText: () -> "entry_option".l() + title: () -> "entry_title".l() ways: ["corridor"] - dsc: """ - Вы находитесь в красивой подводной прихожей. За прозрачными стенами плавают рыбки. - """ + desc: () -> "entry_dsc".l() croom "corridor", ways: ["entry"] - title: "Коридор" - dsc: """ - Короткий коридор, который замыкается в себе. - """ + title: () -> "corridor_title".l() + desc: () -> "corridor_dsc".l() diff --git a/game/translations/en.cson b/game/translations/en.cson new file mode 100644 index 0000000..47ce7d7 --- /dev/null +++ b/game/translations/en.cson @@ -0,0 +1,25 @@ +intro: """ + You are Astrid. + + Astrid sleeps and sees herself in her dreams. + In a dream all people are equal because they are Astrid. +""" +room_enter: "And then enters the " +entry_option: "Be Astrid" +entry_title: "Guest room" +entry_dsc: """ + You are in a beautiful underwater guest room. + There are water horseys swimming behind the glass walls. +""" +corridor_title: "Corridor" +corridor_dsc: """ + A short corridor that turns upon itself. +""" +names: [ + 'red Astrid', + 'Astrid the menace', + 'magic Astrid mermaid', + 'witch Astrid', + "Astridulhu" + "Dent. Astrident" +] diff --git a/game/translations/ru.cson b/game/translations/ru.cson new file mode 100644 index 0000000..464fe4c --- /dev/null +++ b/game/translations/ru.cson @@ -0,0 +1,24 @@ +intro: """ + Вы — Астрид. + + Астрид спит и видит себя. + Во сне все люди равны, потому что все они — Астрид. +""" +room_enter: "В комнату входит " +entry_option: "Быть Астрид" +entry_title: "Прихожая" +entry_dsc: """ + Вы находитесь в красивой подводной прихожей. За прозрачными стенами плавают рыбки. +""" +corridor_title: "Коридор" +corridor_dsc: """ + Короткий коридор, который замыкается в себе. +""" +names: [ + 'рыжая Астрид', + 'Астрид-хулиганка', + 'волшебная русалка Астрид', + 'Астрид-ведьма', + "Астридулху" + "Дент. Астридент" +] diff --git a/html/en.html b/html/en.html new file mode 100644 index 0000000..cad96af --- /dev/null +++ b/html/en.html @@ -0,0 +1,65 @@ + + + + + Being Astrid + + + + + + +
+
+
+
+ These are the adjacent rooms. + +
+
+ + +
+
+
+
+
+
+
+

Being Astrid

+ +
+
+
+
+
+
+ +
+
+
+
+ +
+ +
+
+ + + + + + + + + + diff --git a/html/index.html b/html/index.html index 937fe58..2b4f6dc 100644 --- a/html/index.html +++ b/html/index.html @@ -1,5 +1,5 @@ - + Быть Астрид @@ -37,11 +37,6 @@
-

Вы — Астрид.

- -

Астрид спит и видит себя.

-

Во сне все люди равны, потому что все они — Астрид.

-
diff --git a/package.json b/package.json index 4fb3288..0db82d1 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "gulp-util": "^3.0.8", "gulp-zip": "^3.0.2", "vinyl-buffer": "^1.0.0", - "vinyl-source-stream": "^1.1.0" + "vinyl-source-stream": "^1.1.0", + "cson": "^4.0.0" } }