boom: Updated to new plugin model
This commit is contained in:
parent
e510a90bc4
commit
f327526fca
11 changed files with 831 additions and 927 deletions
|
@ -4,51 +4,54 @@
|
|||
<h4 align="center"><em> <a title="Go to freesewing.org" href="https://freesewing.org/">freesewing</a></em>
|
||||
<br><sup>a library for made-to-measure sewing patterns</sup>
|
||||
</h4>
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/freesewing/plugin-i18n"><img src="https://badgen.net/travis/freesewing/plugin-i18n/master" alt="Travis build"></a>
|
||||
<a href="https://www.npmjs.com/package/@freesewing/plugin-i18n"><img src="https://badgen.net/npm/v/@freesewing/plugin-i18n" alt="Version"></a>
|
||||
<a href="https://www.npmjs.com/package/@freesewing/plugin-i18n"><img src="https://badgen.net/npm/license/@freesewing/plugin-i18n" alt="License"></a>
|
||||
<a href="https://codecov.io/gh/freesewing/plugin-i18n"><img src="https://badgen.net/codecov/c/github/freesewing/plugin-i18n/master" alt="Code coverage"></a>
|
||||
<a href="https://deepscan.io/dashboard#view=project&pid=3254&bid=27564"><img src="https://deepscan.io/api/projects/3254/branches/27564/badge/grade.svg" alt="DeepScan grade"></a>
|
||||
<a href="https://gitter.im/freesewing/freesewing"><img src="https://badgen.net/badge/chat/on%20Gitter/cyan" alt="Chat on Gitter"></a>
|
||||
<a href="https://freesewing.org/patrons/join"><img src="https://badgen.net/badge/become/a%20Patron/FF5B77" alt="Become a Patron"></a>
|
||||
</p>
|
||||
|
||||
# plugin-theme
|
||||
|
||||
A freesewing plugin to provide styles for freesewing. This plugin also provides the `notch` snippet.
|
||||
# plugin-i18n
|
||||
|
||||
## Usage
|
||||
|
||||
To load this plugin, add it to your instantiated pattern.
|
||||
|
||||
On node.js:
|
||||
|
||||
```js
|
||||
import pattern from '@freesewing/pattern-brian'
|
||||
import theme from '@freesewing/plugin-theme'
|
||||
|
||||
pattern.with(theme);
|
||||
```
|
||||
|
||||
In the browser, this plugin will register as `freesewing.plugins.theme`:
|
||||
|
||||
```html
|
||||
<script type="text/javascript" src="https://unpkg.com/freesewing"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/@freesewing/pattern-brian"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/@freesewing/plugin-theme"></script>
|
||||
|
||||
<script>
|
||||
var pattern = freesewing.patterns.brian
|
||||
.with(freesewing.plugins.theme);
|
||||
</script>
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
This plugin adds the following CSS classes to your SVG file:
|
||||
|
||||

|
||||
|
||||
In addition, it adds the `notch` and `bnotch` snippets to your SVG file's defs section.
|
||||
A freesewing plugin to provide translation to your patterns.
|
||||
|
||||
## Install
|
||||
|
||||
To install, run:
|
||||
On node.js:
|
||||
|
||||
```sh
|
||||
npm install @freesewing/plugin-theme
|
||||
npm install @freesewing/plugin-i18n
|
||||
```
|
||||
|
||||
in the browser, simply include the plugin from unpkg:
|
||||
|
||||
```html
|
||||
<script type="text/javascript" src="https://unpkg.com/@freesewing/plugin-i18n"></script>
|
||||
```
|
||||
This plugin will register as `freesewing.plugins.i18n`.
|
||||
|
||||
## Loading this plugin and providing translation data
|
||||
|
||||
This plugin does not come with translations. You should provide the translations
|
||||
when registering the plugin.
|
||||
|
||||
Perhaps you want to use your own translations, or you can use ours from the
|
||||
[@freesewing/i18n](https://www.npmjs.com/package/@freesewing/i18n) package.
|
||||
Note that if you use ours, you only need to add the `plugin` export:
|
||||
|
||||
```js
|
||||
import brian from '@freesewing/brian';
|
||||
import i18nPlugin from '@freesewing/plugin-grainline';
|
||||
import { plugin } from '@freesewing/i18n';
|
||||
|
||||
const pattern = new Brian().with(i18nPlugin, {
|
||||
prefix: "plugin.",
|
||||
strings: plugin
|
||||
});
|
||||
```
|
||||
|
||||
## Build
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import patterns from './patterns';
|
||||
import plugins from './plugins';
|
||||
|
||||
export default {
|
||||
en: {
|
||||
...patterns.en,
|
||||
...plugins.en
|
||||
},
|
||||
nl: {
|
||||
...patterns.nl,
|
||||
...plugins.nl
|
||||
}
|
||||
};
|
|
@ -1,13 +0,0 @@
|
|||
import aaron from "./patterns/aaron";
|
||||
import brian from "./patterns/brian";
|
||||
|
||||
export default {
|
||||
en: {
|
||||
...aaron.en,
|
||||
...brian.en,
|
||||
},
|
||||
nl: {
|
||||
...aaron.nl,
|
||||
...brian.nl,
|
||||
}
|
||||
};
|
|
@ -1,18 +0,0 @@
|
|||
export default {
|
||||
en: {
|
||||
front: "Front",
|
||||
back: "Back",
|
||||
width: "Width",
|
||||
length: "Length",
|
||||
cutTwoStripsToFinishTheArmholes: "Cut two strips to finish the armholes",
|
||||
cutOneStripToFinishTheNeckOpening: "Cut one strip to finish the neck opening"
|
||||
},
|
||||
nl: {
|
||||
front: "Voorzijde",
|
||||
back: "Rug",
|
||||
width: "Breedte",
|
||||
length: "Lengte",
|
||||
cutTwoStripsToFinishTheArmholes: "Knip twee repels om de armsgaten af te werken",
|
||||
cutOneStripToFinishTheNeckOpening: "Knip één repel om de halsopening af te werken"
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
export default {
|
||||
en: {
|
||||
front: "Front",
|
||||
back: "Back",
|
||||
sleeve: "Sleeve"
|
||||
},
|
||||
nl: {
|
||||
front: "Voorzijde",
|
||||
back: "Rug",
|
||||
sleeve: "Mouw"
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
import scalebox from "./plugins/scalebox";
|
||||
import cutonfold from "./plugins/cutonfold";
|
||||
import grainline from "./plugins/grainline";
|
||||
|
||||
export default {
|
||||
en: {
|
||||
...scalebox.en,
|
||||
...cutonfold.en,
|
||||
...grainline.en
|
||||
},
|
||||
nl: {
|
||||
...scalebox.nl,
|
||||
...cutonfold.nl,
|
||||
...grainline.nl
|
||||
}
|
||||
};
|
|
@ -1,10 +0,0 @@
|
|||
export default {
|
||||
en: {
|
||||
cutOnFold: 'Cut on fold',
|
||||
cutOnFoldAndGrainline: 'Cut on fold / Grainline',
|
||||
},
|
||||
nl: {
|
||||
cutOnFold: 'Knippen op de stofvouw',
|
||||
cutOnFoldAndGrainline: 'Knippen op de stofvouw / Draadrichtinge',
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
export default {
|
||||
en: {
|
||||
grainline: 'Grainline'
|
||||
},
|
||||
nl: {
|
||||
grainline: 'Draadrichting'
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
export default {
|
||||
en: {
|
||||
freesewingIsMadeByJoostDeCockAndContributors: "Freesewing is made by Joost De Cock & contributors",
|
||||
withTheFinancialSupportOfOurPatrons: "with the financial support of our patrons",
|
||||
theWhiteInsideOfThisBoxShouldMeasure: "The (white) inside of this box should measure",
|
||||
theBlackOutsideOfThisBoxShouldMeasure: "The (blac) outside of this box should measure"
|
||||
},
|
||||
nl: {
|
||||
freesewingIsMadeByJoostDeCockAndContributors: "Freesewing is gemaakt door Joost De Cock & medewerkers",
|
||||
withTheFinancialSupportOfOurPatrons: "met de financiële steun van onze sponsors",
|
||||
theWhiteInsideOfThisBoxShouldMeasure: "De (witte) binnenkant van dit kader heeft als afmetingen",
|
||||
theBlackOutsideOfThisBoxShouldMeasure: "De (zwarte) buitenkant van dit kader heeft als afmetingen"
|
||||
}
|
||||
}
|
1561
packages/plugin-i18n/package-lock.json
generated
1561
packages/plugin-i18n/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,18 +1,18 @@
|
|||
import { version, name } from "../package.json";
|
||||
import locales from "../locales";
|
||||
|
||||
export default {
|
||||
name: name,
|
||||
version: version,
|
||||
hooks: {
|
||||
preRender: function(next) {
|
||||
this.attributes.add("freesewing:plugin-i18n", version);
|
||||
next();
|
||||
preRender: function(svg) {
|
||||
if(svg.attributes.get('freesewing:plugin-i18n') === false) {
|
||||
svg.attributes.set('freesewing:plugin-i18n', version);
|
||||
}
|
||||
},
|
||||
insertText: function(next) {
|
||||
if(typeof locales[this.pattern.settings.locale][this.text] === 'string')
|
||||
this.text = locales[this.pattern.settings.locale][this.text];
|
||||
next();
|
||||
insertText: function(locale, text, data) {
|
||||
let prefix = data.prefix || "";
|
||||
if(typeof data.strings[locale][prefix+text] === "undefined") return text;
|
||||
else return data.strings[locale][prefix+text];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue