@yiiamee/multilinguist 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,7 +31,7 @@ export default defineNuxtConfig({
31
31
  })
32
32
  ```
33
33
 
34
- Then, create a "locales" directory in /public directory. This is necessary for module to access your languages.
34
+ Then, create a "locales" directory in root directory of your project.
35
35
 
36
36
  ![directory_structure.png](directory_structure.png)
37
37
 
@@ -82,6 +82,24 @@ export default defineNuxtConfig({
82
82
  })
83
83
  ```
84
84
 
85
+ Also, if you want to use a different folder name for your locales' files, or you want to specify other path to the directory, you can set the `localesPath` option in your nuxt.config:
86
+
87
+ ```nuxt.config.ts
88
+ export default defineNuxtConfig({
89
+ modules: [
90
+ "@yiiamee/multilinguist",
91
+ ],
92
+ multilinguist: {
93
+ defaultLocale: "en",
94
+ supportedLanguages: ["en", "es"],
95
+ logging: false,
96
+ setBrowserLanguage: false, // by default: true
97
+ localesPath: "./languages", // by default: "./locales"
98
+ },
99
+ })
100
+ ```
101
+
102
+ ### Important! Keep in mind, that it is not recommended to use "public" folder for your locales' files, as it may lead to rendering, security and other issues.
85
103
 
86
104
  # Usage
87
105
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yiiamee/multilinguist",
3
3
  "configKey": "multilinguist",
4
- "version": "1.5.1",
4
+ "version": "1.5.2",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.0.0 || ^4.0.0"
7
7
  },
@@ -10,7 +10,7 @@
10
10
  "defaultLocale": "",
11
11
  "supportedLanguages": [],
12
12
  "setBrowserLanguage": true,
13
- "localesPath": "./public/locales"
13
+ "localesPath": "./locales"
14
14
  },
15
15
  "builder": {
16
16
  "@nuxt/module-builder": "1.0.1",
package/dist/module.mjs CHANGED
@@ -82,7 +82,7 @@ const module = defineNuxtModule({
82
82
  meta: {
83
83
  name: "@yiiamee/multilinguist",
84
84
  configKey: "multilinguist",
85
- version: "1.5.1",
85
+ version: "1.5.2",
86
86
  compatibility: {
87
87
  nuxt: "^3.0.0 || ^4.0.0"
88
88
  },
@@ -91,12 +91,12 @@ const module = defineNuxtModule({
91
91
  defaultLocale: "",
92
92
  supportedLanguages: [],
93
93
  setBrowserLanguage: true,
94
- localesPath: "./public/locales"
94
+ localesPath: "./locales"
95
95
  }
96
96
  },
97
97
  setup(moduleOptions, nuxtApp) {
98
98
  const resolver = createResolver(import.meta.url);
99
- const localesPath = moduleOptions.localesPath || "./public/locales";
99
+ const localesPath = moduleOptions.localesPath || "./locales";
100
100
  const resolvedLocalesPath = resolve(nuxtApp.options.rootDir, localesPath);
101
101
  addPlugin(resolver.resolve("runtime/plugin"));
102
102
  addImportsDir(resolver.resolve("runtime/composables"));
@@ -11,7 +11,7 @@ export default function useLocalization(supportedLanguages, defaultLocale, setBr
11
11
  const loadLocaleMessages = async (locale2) => {
12
12
  if (!loadedLanguages.value[locale2]) {
13
13
  try {
14
- const localesPath = config.public.multilinguist.localesPath || "./public/locales";
14
+ const localesPath = config.public.multilinguist.localesPath || "./locales";
15
15
  const normalizedPath = localesPath.startsWith("./") ? localesPath.slice(2) : localesPath.startsWith("/") ? localesPath.slice(1) : localesPath;
16
16
  let messages;
17
17
  if (import.meta.server) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yiiamee/multilinguist",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Nuxt Multilinguist module for localizations",
5
5
  "repository": "yiiameeMich/multilinguist",
6
6
  "license": "MIT",