@jshmrtn/vue3-gettext
Advanced tools
Comparing version 0.3.2 to 1.0.0
@@ -51,2 +51,3 @@ "use strict"; | ||
el.dataset.msgid = el.innerHTML; | ||
console.log(el.innerHTML); | ||
} | ||
@@ -53,0 +54,0 @@ vue_1.watch(language, function () { |
@@ -0,3 +1,3 @@ | ||
import { App, UnwrapRef, Directive as VueDirective, WritableComputedRef } from "vue"; | ||
import Component from "./component"; | ||
import { App, UnwrapRef, WritableComputedRef, Directive as VueDirective } from "vue"; | ||
export interface GetTextOptions { | ||
@@ -4,0 +4,0 @@ availableLanguages: { |
@@ -15,2 +15,3 @@ "use strict"; | ||
exports.useGettext = exports.createGettext = exports.GetTextSymbol = void 0; | ||
var vue_1 = require("vue"); | ||
var component_1 = require("./component"); | ||
@@ -20,3 +21,2 @@ var directive_1 = require("./directive"); | ||
var translate_1 = require("./translate"); | ||
var vue_1 = require("vue"); | ||
var utils_1 = require("./utils"); | ||
@@ -29,3 +29,3 @@ var defaultOptions = { | ||
translations: {}, | ||
setGlobalProperties: false, | ||
setGlobalProperties: true, | ||
provideDirective: true, | ||
@@ -90,3 +90,4 @@ provideComponent: true, | ||
exports.createGettext = createGettext; | ||
exports.useGettext = function () { return vue_1.inject(exports.GetTextSymbol); }; | ||
var useGettext = function () { return vue_1.inject(exports.GetTextSymbol); }; | ||
exports.useGettext = useGettext; | ||
//# sourceMappingURL=index.js.map |
declare const _default: { | ||
getTranslationIndex: (languageCode: any, n: any) => 1 | 0 | 2 | 4 | 3 | 5; | ||
getTranslationIndex: (languageCode: any, n: any) => 1 | 2 | 3 | 4 | 5 | 0; | ||
}; | ||
@@ -4,0 +4,0 @@ /** |
@@ -49,2 +49,3 @@ import interpolate from "./interpolate"; | ||
el.dataset.msgid = el.innerHTML; | ||
console.log(el.innerHTML); | ||
} | ||
@@ -51,0 +52,0 @@ watch(language, function () { |
@@ -0,3 +1,3 @@ | ||
import { App, UnwrapRef, Directive as VueDirective, WritableComputedRef } from "vue"; | ||
import Component from "./component"; | ||
import { App, UnwrapRef, WritableComputedRef, Directive as VueDirective } from "vue"; | ||
export interface GetTextOptions { | ||
@@ -4,0 +4,0 @@ availableLanguages: { |
@@ -12,2 +12,3 @@ var __assign = (this && this.__assign) || function () { | ||
}; | ||
import { computed, inject, reactive } from "vue"; | ||
import Component from "./component"; | ||
@@ -17,3 +18,2 @@ import Directive from "./directive"; | ||
import translateRaw from "./translate"; | ||
import { reactive, inject, computed } from "vue"; | ||
import { normalizeTranslations } from "./utils"; | ||
@@ -26,3 +26,3 @@ var defaultOptions = { | ||
translations: {}, | ||
setGlobalProperties: false, | ||
setGlobalProperties: true, | ||
provideDirective: true, | ||
@@ -29,0 +29,0 @@ provideComponent: true, |
declare const _default: { | ||
getTranslationIndex: (languageCode: any, n: any) => 1 | 0 | 2 | 4 | 3 | 5; | ||
getTranslationIndex: (languageCode: any, n: any) => 1 | 2 | 3 | 4 | 5 | 0; | ||
}; | ||
@@ -4,0 +4,0 @@ /** |
{ | ||
"name": "@jshmrtn/vue3-gettext", | ||
"version": "0.3.2", | ||
"version": "1.0.0", | ||
"description": "Translate your Vue.js applications with gettext", | ||
@@ -36,22 +36,22 @@ "author": "Leo Zurbriggen", | ||
"vue": "^3.0.0", | ||
"easygettext": "^2.15.0" | ||
"easygettext": "^2.16.1" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.9", | ||
"@types/node": "^14.0.27", | ||
"@typescript-eslint/parser": "^4.4.1", | ||
"@types/jest": "^26.0.15", | ||
"@types/node": "^14.14.10", | ||
"@typescript-eslint/parser": "^4.9.0", | ||
"@vue/test-utils": "^2.0.0-beta.6", | ||
"date-fns": "^2.15.0", | ||
"easygettext": "^2.15.0", | ||
"eslint": "^7.11.0", | ||
"eslint-config-prettier": "^6.12.0", | ||
"eslint-plugin-vue": "^7.0.0-beta.4", | ||
"jest": "^26.4.0", | ||
"json-loader": "^0.5.4", | ||
"prettier": "^2.1.2", | ||
"ts-jest": "^26.2.0", | ||
"typescript": "^3.9.7", | ||
"vite": "^1.0.0-rc.8", | ||
"date-fns": "^2.16.1", | ||
"easygettext": "^2.16.1", | ||
"eslint": "^7.14.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-vue": "^7.1.0", | ||
"jest": "^26.6.3", | ||
"json-loader": "^0.5.7", | ||
"prettier": "^2.2.1", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.2", | ||
"vite": "^1.0.0-rc.13", | ||
"vue": "^3.0.0", | ||
"vue-loader": "^10.3.0" | ||
"vue-loader": "^15.9.5" | ||
}, | ||
@@ -58,0 +58,0 @@ "main": "dist/commonjs/index.js", |
# vue3-gettext | ||
> :warning: **WIP**: This project is based on the original [vue-gettext](https://github.com/Polyconseil/vue-gettext). It has not yet been used in production. Parts of the readme have not been updated yet. | ||
> :warning: This project is based on the original [vue-gettext](https://github.com/Polyconseil/vue-gettext). It has not yet been used in production. | ||
@@ -180,5 +180,5 @@ Translate [Vue.js](http://vuejs.org) applications with [gettext](https://en.wikipedia.org/wiki/Gettext). | ||
Default: `false` | ||
Default: `true` | ||
Sets the options `$gettext` `$pgettext` `$ngettext` `$npgettext` `$gettextInterpolate` `$language` on `app.config.globalProperties`, making the globally available in your templates. This is a compatibility option meant for projects upgrading from `vue-gettext` and activating it is **not** recommended. | ||
Sets the options `$gettext` `$pgettext` `$ngettext` `$npgettext` `$gettextInterpolate` `$language` on `app.config.globalProperties`, making the globally available in your templates. It is **not** recommended to disable this as `easygettext` will not extract strings if your functions are not named exactly like this. | ||
@@ -371,29 +371,6 @@ ### `provideDirective` | ||
#### Caveat when using `v-translate` with interpolation | ||
> :warning: **TODO**: Section not updated | ||
It's not possible (yet) to detect changes on the parent component's data, so you have to add an expression to the directive to provide a changing binding value. This is so that it can do a comparison on old and current value before running the translation in its `update` hook. | ||
It is described in the [official guide](https://vuejs.org/v2/guide/custom-directive.html#Hook-Functions): | ||
> update: called after the containing component has updated, but possibly before its children have updated. The directive's value may or may not have changed, but you can skip unnecessary updates by comparing the binding's current and old values... | ||
```html | ||
<p | ||
v-translate="{count: count, brand: brand}" | ||
:translate-n="count" | ||
translate-plural="<strong>%{ count }</strong> %{brand} cars" | ||
translate-comment="My comment for translators" | ||
> | ||
<strong>%{ count }</strong> %{brand} car | ||
</p> | ||
``` | ||
#### Caveat when using either the component `<translate>` or directive `v-translate` with interpolation inside `v-for` | ||
> :warning: **TODO**: Section not updated | ||
It's not possible to access the scope within `v-for`, example: | ||
It's not possible (yet) to access the scope within `v-for`, example: | ||
```html | ||
@@ -419,6 +396,4 @@ <p> | ||
> :warning: **TODO**: Section not updated | ||
It's not possible to support components or attributes like `v-bind` and `v-on`. So make sure that your HTML translations stay basic for now. | ||
It's not possible (yet) to support components or attributes like `v-bind` and `v-on`. So make sure that your HTML translations stay basic for now. | ||
For example, this is _not supported_: | ||
@@ -425,0 +400,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1755
1
128702
464