added missing modules for makepot task + added suport for plural forms in html templates + added all major i18n methods in twig

This commit is contained in:
Jonathan Labreuille
2015-07-29 19:15:21 +02:00
parent acc3854ba9
commit ec20abb1ee
868 changed files with 178636 additions and 71 deletions

View File

@@ -0,0 +1,15 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"node": true,
"es5": true
}

View File

@@ -0,0 +1 @@
/node_modules/

View File

@@ -0,0 +1,6 @@
language: node_js
node_js:
- "0.8"
- "0.10"
before_script:
- npm install -g grunt-cli

View File

@@ -0,0 +1,48 @@
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
nodeunit: {
files: ['test/**/*_test.js'],
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['lib/**/*.js']
},
test: {
src: ['test/*.js']
},
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib: {
files: '<%= jshint.lib.src %>',
tasks: ['jshint:lib', 'nodeunit']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'nodeunit']
},
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task.
grunt.registerTask('default', ['jshint', 'nodeunit']);
};

View File

@@ -0,0 +1,22 @@
Copyright (c) 2013 "Cowboy" Ben Alman
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,20 @@
# getobject [![Build Status](https://secure.travis-ci.org/cowboy/node-getobject.png?branch=master)](http://travis-ci.org/cowboy/node-getobject)
get.and.set.deep.objects.easily = true;
## Getting Started
Install the module with: `npm install getobject`
```javascript
var getobject = require('getobject');
```
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
## Release History
_(Nothing yet)_
## License
Copyright (c) 2013 "Cowboy" Ben Alman
Licensed under the MIT license.

View File

@@ -0,0 +1,60 @@
/*
* getobject
* https://github.com/cowboy/node-getobject
*
* Copyright (c) 2013 "Cowboy" Ben Alman
* Licensed under the MIT license.
*/
'use strict';
var getobject = module.exports = {};
// Split strings on dot, but only if dot isn't preceded by a backslash. Since
// JavaScript doesn't support lookbehinds, use a placeholder for "\.", split
// on dot, then replace the placeholder character with a dot.
function getParts(str) {
return str.replace(/\\\./g, '\uffff').split('.').map(function(s) {
return s.replace(/\uffff/g, '.');
});
}
// Get the value of a deeply-nested property exist in an object.
getobject.get = function(obj, parts, create) {
if (typeof parts === 'string') {
parts = getParts(parts);
}
var part;
while (typeof obj === 'object' && obj && parts.length) {
part = parts.shift();
if (!(part in obj) && create) {
obj[part] = {};
}
obj = obj[part];
}
return obj;
};
// Set a deeply-nested property in an object, creating intermediary objects
// as we go.
getobject.set = function(obj, parts, value) {
parts = getParts(parts);
var prop = parts.pop();
obj = getobject.get(obj, parts, true);
if (obj && typeof obj === 'object') {
return (obj[prop] = value);
}
};
// Does a deeply-nested property exist in an object?
getobject.exists = function(obj, parts) {
parts = getParts(parts);
var prop = parts.pop();
obj = getobject.get(obj, parts);
return typeof obj === 'object' && obj && prop in obj;
};

View File

@@ -0,0 +1,66 @@
{
"name": "getobject",
"description": "get.and.set.deep.objects.easily = true",
"version": "0.1.0",
"homepage": "https://github.com/cowboy/node-getobject",
"author": {
"name": "\"Cowboy\" Ben Alman",
"url": "http://benalman.com/"
},
"repository": {
"type": "git",
"url": "git://github.com/cowboy/node-getobject.git"
},
"bugs": {
"url": "https://github.com/cowboy/node-getobject/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/cowboy/node-getobject/blob/master/LICENSE-MIT"
}
],
"main": "lib/getobject",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt nodeunit"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt-contrib-watch": "~0.2.0",
"grunt": "~0.4.1"
},
"keywords": [
"dot notation",
"properties",
"get",
"set",
"object",
"dot"
],
"readme": "# getobject [![Build Status](https://secure.travis-ci.org/cowboy/node-getobject.png?branch=master)](http://travis-ci.org/cowboy/node-getobject)\n\nget.and.set.deep.objects.easily = true;\n\n## Getting Started\nInstall the module with: `npm install getobject`\n\n```javascript\nvar getobject = require('getobject');\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n_(Nothing yet)_\n\n## License\nCopyright (c) 2013 \"Cowboy\" Ben Alman\nLicensed under the MIT license.",
"readmeFilename": "README.md",
"_id": "getobject@0.1.0",
"dist": {
"shasum": "047a449789fa160d018f5486ed91320b6ec7885c",
"tarball": "http://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz"
},
"_from": "getobject@~0.1.0",
"_npmVersion": "1.3.11",
"_npmUser": {
"name": "tkellen",
"email": "tyler@sleekcode.net"
},
"maintainers": [
{
"name": "tkellen",
"email": "tyler@sleekcode.net"
}
],
"directories": {},
"_shasum": "047a449789fa160d018f5486ed91320b6ec7885c",
"_resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz"
}

View File

@@ -0,0 +1,51 @@
'use strict';
var getobject = require('../lib/getobject');
exports.get = {
'no create': function(test) {
var obj = {a: {b: {c: 1, d: '', e: null, f: undefined, 'g.h.i': 2}}};
test.strictEqual(getobject.get(obj, 'a'), obj.a, 'should get immediate properties.');
test.strictEqual(getobject.get(obj, 'a.b'), obj.a.b, 'should get nested properties.');
test.strictEqual(getobject.get(obj, 'a.x'), undefined, 'should return undefined for nonexistent properties.');
test.strictEqual(getobject.get(obj, 'a.b.c'), 1, 'should return values.');
test.strictEqual(getobject.get(obj, 'a.b.d'), '', 'should return values.');
test.strictEqual(getobject.get(obj, 'a.b.e'), null, 'should return values.');
test.strictEqual(getobject.get(obj, 'a.b.f'), undefined, 'should return values.');
test.strictEqual(getobject.get(obj, 'a.b.g\\.h\\.i'), 2, 'literal backslash should escape period in property name.');
test.done();
},
'create': function(test) {
var obj = {a: 1};
test.strictEqual(getobject.get(obj, 'a', true), obj.a, 'should just return existing properties.');
test.strictEqual(getobject.get(obj, 'b', true), obj.b, 'should create immediate properties.');
test.strictEqual(getobject.get(obj, 'c.d.e', true), obj.c.d.e, 'should create nested properties.');
test.done();
}
};
exports.set = function(test) {
var obj = {};
test.strictEqual(getobject.set(obj, 'a', 1), 1, 'should return immediate property value.');
test.strictEqual(obj.a, 1, 'should set property value.');
test.strictEqual(getobject.set(obj, 'b.c.d', 1), 1, 'should return nested property value.');
test.strictEqual(obj.b.c.d, 1, 'should set property value.');
test.strictEqual(getobject.set(obj, 'e\\.f\\.g', 1), 1, 'literal backslash should escape period in property name.');
test.strictEqual(obj['e.f.g'], 1, 'should set property value.');
test.done();
};
exports.exists = function(test) {
var obj = {a: {b: {c: 1, d: '', e: null, f: undefined, 'g.h.i': 2}}};
test.ok(getobject.exists(obj, 'a'), 'immediate property should exist.');
test.ok(getobject.exists(obj, 'a.b'), 'nested property should exist.');
test.ok(getobject.exists(obj, 'a.b.c'), 'nested property should exist.');
test.ok(getobject.exists(obj, 'a.b.d'), 'nested property should exist.');
test.ok(getobject.exists(obj, 'a.b.e'), 'nested property should exist.');
test.ok(getobject.exists(obj, 'a.b.f'), 'nested property should exist.');
test.ok(getobject.exists(obj, 'a.b.g\\.h\\.i'), 'literal backslash should escape period in property name.');
test.equal(getobject.exists(obj, 'x'), false, 'nonexistent property should not exist.');
test.equal(getobject.exists(obj, 'a.x'), false, 'nonexistent property should not exist.');
test.equal(getobject.exists(obj, 'a.b.x'), false, 'nonexistent property should not exist.');
test.done();
};