@flix-tech/stencil-i18n
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -18,2 +18,6 @@ export interface PluginOptions { | ||
dictionaryPath?: string; | ||
/** | ||
* path to source files that will be translated. If not defined, path will be "src" | ||
*/ | ||
srcPath?: string; | ||
} | ||
@@ -20,0 +24,0 @@ export declare type ImporterReturnType = { |
import * as d from './declarations'; | ||
export declare function usePlugin(fileName: string): boolean; | ||
export declare function usePlugin(fileName: string, srcPath: string): boolean; | ||
export declare function getContext(context: d.PluginCtx): d.PluginCtx; |
import * as fs from 'fs'; | ||
export function usePlugin(fileName) { | ||
export function usePlugin(fileName, srcPath) { | ||
if (typeof fileName === 'string') { | ||
return /(\.jsx|\.js)$/i.test(fileName); | ||
return fileName.startsWith(srcPath) && /(\.tsx|\.jsx|\.ts|\.js)$/i.test(fileName); | ||
} | ||
@@ -6,0 +6,0 @@ return true; |
{ | ||
"name": "@flix-tech/stencil-i18n", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Static translations for stenciljs", | ||
@@ -35,17 +35,17 @@ "author": "FlixMobility Tech", | ||
"dependencies": { | ||
"acorn": "7.2.0", | ||
"acorn-walk": "7.1.1", | ||
"acorn": "7.3.1", | ||
"acorn-walk": "7.2.0", | ||
"astring": "1.4.3" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "8.4.0", | ||
"@types/astring": "1.3.0", | ||
"@types/jest": "25.2.3", | ||
"@types/node": "14.0.10", | ||
"jest": "26.0.1", | ||
"@types/jest": "26.0.4", | ||
"@types/node": "14.0.23", | ||
"jest": "26.1.0", | ||
"rimraf": "3.0.2", | ||
"rollup": "2.13.1", | ||
"rollup-plugin-node-resolve": "5.2.0", | ||
"rollup": "2.21.0", | ||
"tslint": "6.1.2", | ||
"tslint-ionic-rules": "0.0.21", | ||
"typescript": "3.9.3" | ||
"typescript": "3.9.6" | ||
}, | ||
@@ -52,0 +52,0 @@ "jest": { |
[![Build Status](https://travis-ci.org/flix-tech/stencil-i18n.svg?branch=master)](https://travis-ci.org/flix-tech/stencil-i18n) | ||
# Static translations (Stencil plugin) | ||
@@ -7,2 +8,3 @@ | ||
## Getting started | ||
```bash | ||
@@ -13,2 +15,3 @@ npm i @flix-tech/stencil-i18n | ||
configure it in `stencil.config.js` | ||
```javascript | ||
@@ -23,3 +26,4 @@ const { i18n } = require('@flix-tech/stencil-i18n'); | ||
functionName: 'i18n', // default value is i18n | ||
dictionaryPath: 'src/i18n' | ||
dictionaryPath: 'src/i18n', | ||
srcPath: 'src' // default value is src | ||
}) | ||
@@ -47,2 +51,3 @@ ] | ||
Import the dummy function defined before. | ||
```javascript | ||
@@ -68,7 +73,7 @@ const param3 = 'bye'; | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.scss'] | ||
styleUrls: ['./app.component.scss'], | ||
}) | ||
export class AppComponent { | ||
constructor(@Inject(LOCALE_ID) locale: string) { | ||
import(`<YOUR_COMPONENT_NAME>/dist/${locale}/loader`).then(webcomponent => { | ||
import(`<YOUR_COMPONENT_NAME>/dist/${locale}/loader`).then((webcomponent) => { | ||
webcomponent.defineCustomElements(window); | ||
@@ -78,3 +83,2 @@ }); | ||
} | ||
``` | ||
``` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
479361
12169
79
+ Addedacorn@7.3.1(transitive)
+ Addedacorn-walk@7.2.0(transitive)
- Removedacorn@7.2.0(transitive)
- Removedacorn-walk@7.1.1(transitive)
Updatedacorn@7.3.1
Updatedacorn-walk@7.2.0