From d9d1cbf87d74bdd134585d58dbc953e3595a3453 Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Thu, 14 Jan 2016 19:22:44 +0100 Subject: [PATCH] Add String resource class --- src/common/res.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/res.js b/src/common/res.js index bcd941dfe..c7f118cca 100644 --- a/src/common/res.js +++ b/src/common/res.js @@ -20,8 +20,8 @@ class Resource { return yaml.safeLoad(data) } - static async open(name) { - return new this(this.parse(await read(this.expand(name)))) + static async open(name, ...args) { + return new this(this.parse(await read(this.expand(name))), ...args) } static expand(name) { @@ -42,7 +42,14 @@ class Menu extends Resource { } } +class Strings extends Resource { + static get base() { return join(super.base, 'strings') } + + constructor(data = {}, locale = 'en') { + this.data = data[locale] + } +} + module.exports = { - Resource, - Menu + Resource, Menu, Strings }