Skip to content

Commit

Permalink
Merge pull request #397 from rtrap95/main
Browse files Browse the repository at this point in the history
feat: add locale configuration support for Appwrite client
  • Loading branch information
Hrdtr authored Feb 27, 2025
2 parents e156dd7 + 384de25 commit a7efef7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ Appwrite API endpoint (Console -> Project -> Setting -> API Endpoint)

Appwrite project ID (Console -> Project -> Setting -> Project ID)

### Locale - `locale` - optional

- type: `String`
- default: `en`

Appwrite locale

### Full Example

```js
Expand All @@ -60,6 +67,7 @@ export default {
appwrite: {
endpoint: 'https://cloud.appwrite.io/v1',
project: 'nuxt-playground',
locale: 'en'
}
}
```
Expand Down Expand Up @@ -108,4 +116,4 @@ Copyright (c) Herdi Tr. <[email protected]>
[codecov-href]: https://codecov.io/gh/Hrdtr/nuxt-appwrite

[license-src]: https://img.shields.io/npm/l/nuxt-appwrite.svg
[license-href]: https://npmjs.com/package/nuxt-appwrite
[license-href]: https://npmjs.com/package/nuxt-appwrite
3 changes: 3 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.hook('listen', () => {
console.info(`Appwrite Endpoint: ${options.endpoint}`)
console.info(`Appwrite Project: ${options.project}`)
if(options.locale){
console.info(`Appwrite Locale: ${options.locale}`)
}
})
},
})
5 changes: 5 additions & 0 deletions src/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { defineNuxtPlugin } from '#app'
export type AppwriteConfig = {
endpoint: string
project: string
locale?: string
}

export type Appwrite = {
Expand Down Expand Up @@ -48,10 +49,14 @@ export default defineNuxtPlugin((nuxtApp) => {
const config: AppwriteConfig = {
endpoint: moduleOptions.endpoint || 'https://cloud.appwrite.io/v1',
project: moduleOptions.project,
locale: moduleOptions.locale,
}
const client = new Client()
client.setEndpoint(config.endpoint)
client.setProject(config.project)
if (config.locale) {
client.setLocale(config.locale)
}

return {
provide: {
Expand Down

0 comments on commit a7efef7

Please sign in to comment.