Skip to content

Commit

Permalink
Used bem-core and bem-bl values for version option
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewblond committed Aug 10, 2015
1 parent 573de8b commit 7a7bbf5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
File renamed without changes.
File renamed without changes.
17 changes: 10 additions & 7 deletions lib/compile/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var compile1 = require('./compile-v1'),
compile2 = require('./compile-v2');
var compileForBemBL = require('./bem-bl'),
compileForBemCore = require('./bem-core');

/**
* Compiles code of i18n for `bem-core` or `bem-bl` localization system.
Expand All @@ -9,14 +9,17 @@ var compile1 = require('./compile-v1'),
* @param {String} core — code that contains i18n core from bem-core or bem-bl library.
* @param {Object} keysets — a sets of keys and their values (translations) for a language to internationalization.
* @param {Object} opts
* @param {String} opts.version — version of core. Use `1` for `bem-bl`, `2` for `bem-core`.
* @param {String} opts.version — version of core: `bem-bl` or `bem-core`.
* @param {String} [opts.language] — language of keysets.
*
* @returns {String}
*/
module.exports = function (core, keysets, opts) {
/*jslint eqeq: true*/
return opts.version == 1 ?
compile1(core, keysets, opts.language) :
compile2(core, keysets);
if (opts.version === 'bem-core') {
return compileForBemCore(core, keysets);
}

if (opts.version === 'bem-bl') {
return compileForBemBL(core, keysets, opts.language);
}
};
4 changes: 2 additions & 2 deletions lib/keysets.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function read(filename, cache, root) {
function parse(keysets) {
var core,
data = {},
version = 2;
version = 'bem-core';

// Pull core from source keysets
keysets && Object.keys(keysets).forEach(function (scope) {
Expand All @@ -58,7 +58,7 @@ function parse(keysets) {
} else if (scope === 'all') {
var possibleCore = keysets[scope][''];
if (possibleCore && (typeof possibleCore === 'string') && possibleCore.match(/BEM\.I18N/g)) {
version = 1;
version = 'bem-bl';
core = possibleCore;
}
} else {
Expand Down

0 comments on commit 7a7bbf5

Please sign in to comment.