Skip to content

Commit

Permalink
Paths are now relative
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-nextbit committed Apr 4, 2016
1 parent 6c9556b commit 576798f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,14 @@ function replace(file, options) {
var params = {};
params.ext = path.extname(file.path).substr(1);
params.name = path.basename(file.path, path.extname(file.path));
params.path = file.base.substr(0, file.base.length - 1);
params.path = file.path.substring(file.base.length, file.path.lastIndexOf('/'));
params.lang = lang;

var filePath = options.filename;
for (var param in params) {
filePath = filePath.replace('${' + param + '}', params[param]);
}
filePath = path.join(file.base,filePath);

var newFile = new gutil.File({
base: file.base,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-international",
"version": "1.0.6",
"version": "1.0.7",
"description": "A gulp plugin that creates multi language versions of your source files",
"license": "Apache-2.0",
"homepage": "http://github.com/mallocator/gulp-international",
Expand Down
20 changes: 18 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,24 @@ You don't have to use this format. Basically any name is valid for the file and
Type: string
Default: ```${path}/${name}-${lang}.${ext}```

This options allows the user to configure the output format as desired. The default will generate all files in the same directory
with the language suffix. A configuration to store each version in it's own path would be: ```${path}/${lang}/${name}.${ext}```
This option allows the user to configure the output format as desired. The default will generate all files in the same directory
with the language suffix.

There are 4 placeholders available:

* ```lang```: The filename of the translation file without extension (e.g. 'en_US')
* ```path```: The relative filepath inside the target directory (e.g. 'static')
* ```name```: The original filename (e.g. 'index')
* ```ext```: The original file extension (e.g. 'html')

Here are a few examples of what the results would be:

```
${path}/${name}-${lang}.${ext} = static/index-en_US.html
${lang}/${path}/${name}.${ext} = en_US/static/index.html
${path}/${name}.${ext}.${lang} = static/index.html.en_US
${lang}/${name}.${ext} = en_US/index.html // ignores the path and copies everything in the same dir
```


### delimiter
Expand Down

0 comments on commit 576798f

Please sign in to comment.