Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace localazy languages #14

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
node-version: '18.18'
app-id: ${{ secrets.AUTH_APP_ID }}
app-key: ${{ secrets.AUTH_APP_KEY }}
run-after-install: npm run set-production-config
run-after-install: npm run build-scripts
monorepo-public-npm-token: ${{ secrets.NPM_AUTH_TOKEN_PUBLIC }}
monorepo-public-npm-publish: |
'extensions/module'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@localazy/directus-extension-localazy-automation",
"description": "The official Localazy hook extension for Directus to automate synchronization of content",
"icon": "cloud_sync",
"version": "1.0.5",
"version": "1.0.7",
"keywords": [
"directus",
"directus-extension",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@localazy/directus-extension-localazy",
"description": "The official Localazy module extension for Directus",
"icon": "translate",
"version": "1.0.5",
"version": "1.0.7",
"keywords": [
"directus",
"directus-extension",
Expand Down Expand Up @@ -35,7 +35,6 @@
"dependencies": {
"@localazy/api-client": "^2.1.5",
"@localazy/generic-connector-client": "^0.2.3",
"@localazy/languages": "^0.1.6",
"@vueuse/core": "^10.2.1",
"pinia": "^2.1.4"
},
Expand Down
4 changes: 4 additions & 0 deletions extensions/common/functions/find-localazy-language.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { getLocalazyLanguages, Language } from './localazy-languages';

export const findLocalazyLanguageByLocale = (locale: string): Language | undefined => getLocalazyLanguages()
.find((language) => language.locale === locale);
1,498 changes: 1,498 additions & 0 deletions extensions/common/functions/localazy-languages.ts

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion extensions/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion extensions/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"dependencies": {
"@localazy/api-client": "^2.1.5",
"@localazy/generic-connector-client": "^0.2.3",
"@localazy/languages": "^0.1.6",
"lodash": "^4.17.21"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion extensions/common/services/directus-localazy-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLocalazyLanguages } from '@localazy/languages';
import { getLocalazyLanguages } from '../functions/localazy-languages';

export class DirectusLocalazyAdapter {
static mapDirectusToLocalazySourceLanguage(localazySourceLanguageId: number, directusSourceLanguage: string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable class-methods-use-this */
import { getLocalazyLanguages } from '@localazy/languages';
import { Language, Project } from '@localazy/api-client';
import { uniqWith } from 'lodash';
import { getLocalazyLanguages } from '../functions/localazy-languages';
import { DirectusApi } from '../interfaces/directus-api';
import { CreateMissingLanguagesInDirectus } from '../enums/create-missing-languages-in-directus';
import { Settings } from '../models/collections-data/settings';
Expand Down
1 change: 0 additions & 1 deletion extensions/module/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion extensions/module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"dependencies": {
"@localazy/api-client": "^2.1.5",
"@localazy/generic-connector-client": "^0.2.3",
"@localazy/languages": "^0.1.6",
"@vueuse/core": "^10.2.1",
"pinia": "^2.1.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
<script lang="ts" setup>
import { storeToRefs } from 'pinia';
import { computed, ref, watch } from 'vue';
import { findLocalazyLanguageByLocale } from '@localazy/languages';
import { uniqWith } from 'lodash';
import { findLocalazyLanguageByLocale } from '../../../../common/functions/find-localazy-language';
import { useLocalazyStore } from '../../stores/localazy-store';
import { useDirectusLanguages } from '../../composables/use-directus-languages';
import { DirectusLocalazyAdapter } from '../../../../common/services/directus-localazy-adapter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<script lang="ts" setup>
import { storeToRefs } from 'pinia';
import { computed } from 'vue';
import { getLocalazyLanguages, findLocalazyLanguageByLocale } from '@localazy/languages';
import { getLocalazyLanguages } from '../../../../common/functions/localazy-languages';
import { useLocalazyStore } from '../../stores/localazy-store';
import { DirectusLocalazyAdapter } from '../../../../common/services/directus-localazy-adapter';

Expand All @@ -94,7 +94,7 @@
.find((lang) => lang.localazyId === localazyProject.value?.sourceLanguage));
const directusSourceLanguage = computed(() => {
if (!settings.value?.source_language) return null;
return findLocalazyLanguageByLocale(

Check failure on line 97 in extensions/module/src/components/Overview/ConnectionOverview.vue

View workflow job for this annotation

GitHub Actions / Lint & build package

'findLocalazyLanguageByLocale' is not defined
DirectusLocalazyAdapter.transformDirectusToLocalazyLanguage(settings.value.source_language),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import {
} from 'vue';
import { AppCollection, Field, Item } from '@directus/types';
import { storeToRefs } from 'pinia';
import { getLocalazyLanguages } from '@localazy/languages';
import { getLocalazyLanguages } from '../../../../common/functions/localazy-languages';
import { SelectItem } from '../../models/directus/internals/select-item';
import { Settings } from '../../../../common/models/collections-data/settings';
import { getConfig } from '../../../../common/config/get-config';
Expand Down
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"watch": ["extensions"],
"ignore": ["**/dist/**", "extensions/common/config/*"],
"ignore": ["**/dist/**", "extensions/common/config/*", "extensions/common/functions/localazy-languages.ts"],
"ext": "ts,js,json,vue",
"exec": "npm run build && npm run copy-dist",
"verbose": false,
Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
"build:hook": "cd ./extensions/sync-hook && ./node_modules/.bin/directus-extension build --no-minify",
"dev": "node ./scripts/assure-config.mjs && docker-compose -f ./development/docker-compose.yml up -d && nodemon --config nodemon.json",
"lint": "eslint --ext .ts,.vue src",
"build-scripts": "npm run set-production-config && node ./scripts/copy-license.mjs",
"build-scripts": "npm run set-production-config && node ./scripts/copy-license.mjs && node ./scripts/generate-localazy-languages.mjs",
"set-production-config": "npm run set-config -- --mode=production",
"set-config": "node ./scripts/set-config.mjs",
"copy-dist": "node ./scripts/copy-dist-to-module.mjs && node ./scripts/copy-dist-to-hook.mjs"
},
"devDependencies": {
"@localazy/languages": "^0.1.11",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.12.11",
"@typescript-eslint/eslint-plugin": "^6.2.0",
Expand Down
19 changes: 19 additions & 0 deletions scripts/generate-localazy-languages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { getLocalazyLanguages } from '@localazy/languages';
import fse from 'fs-extra';

/** '@localazy/languages' exports JSON overview of all languages supported by Localazy.
* However, Directus is unable to parse JSON files in the rollup pipeline.
* Therefore, we need to generate a TypeScript file with the same content while excluding the JSON file.
*/
const generateLocalazyLanguages = async () => {
const languageType = fse.readFileSync('node_modules/@localazy/languages/lib/module/language.d.ts');
let template = `/* eslint-disable */\n${languageType.toString()}\n\n`;

template += 'export const getLocalazyLanguages = (): Language[] => {\n return [\n';
template += getLocalazyLanguages().map((language) => ` ${JSON.stringify(language)},`).join('\n');
template += ' ]};\n';

fse.writeFileSync('./extensions/common/functions/localazy-languages.ts', template);
};

generateLocalazyLanguages();
Loading