Integrate new translations setup

This commit is contained in:
Julie Lenaerts 2025-03-04 14:43:11 +01:00
parent 51cc0254d0
commit 01323ea87a
11 changed files with 114 additions and 61 deletions

4
.env
View File

@ -78,3 +78,7 @@ RELATORIO_HOST=
RELATORIO_PORT=
WOPI_SERVER=http://${COLLABORA_HOST}:${COLLABORA_PORT}
###< chill-project/chill-bundles ###
###> symfony/ovh-cloud-notifier ###
# OVHCLOUD_DSN=ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME
###< symfony/ovh-cloud-notifier ###

View File

@ -0,0 +1,7 @@
import SwaggerUI from 'swagger-ui';
import 'swagger-ui/dist/swagger-ui.css';
SwaggerUI({
url: '/_dev/specs.yaml',
dom_id: '#swag'
})

8
assets/translator.ts Normal file
View File

@ -0,0 +1,8 @@
import { trans, getLocale, setLocale, setLocaleFallbacks } from '@symfony/ux-translator';
setLocaleFallbacks({"en": "fr", "nl": "fr", "fr": "en"});
setLocale('fr');
export { trans };
export * from "../var/translations";

View File

@ -34,4 +34,5 @@ return [
Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\UX\Translator\UxTranslatorBundle::class => ['all' => true],
];

View File

@ -0,0 +1,13 @@
framework:
notifier:
chatter_transports:
texter_transports:
ovhcloud: '%env(OVHCLOUD_DSN)%'
channel_policy:
# use chat/slack, chat/telegram, sms/twilio or sms/nexmo
urgent: ['email']
high: ['email']
medium: ['email']
low: ['email']
admin_recipients:
- { email: admin@example.com }

View File

@ -0,0 +1,3 @@
ux_translator:
# The directory where the JavaScript translations are dumped
dump_directory: '%kernel.project_dir%/var/translations'

View File

@ -11,9 +11,10 @@
"scripts": {
"specs-build": "yaml-merge vendor/chill-project/chill-bundles/src/Bundle/ChillMainBundle/chill.api.specs.yaml vendor/chill-project/chill-bundles/src/Bundle/ChillPersonBundle/chill.api.specs.yaml vendor/chill-project/chill-bundles/src/Bundle/ChillCalendarBundle/chill.api.specs.yaml vendor/chill-project/chill-bundles/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml vendor/chill-project/chill-bundles/src/Bundle/ChillDocStoreBundle/chill.api.specs.yaml> templates/api/specs.yaml",
"specs-validate": "swagger-cli validate templates/api/specs.yaml",
"specs": "yarn run specs-build && yarn run specs-validate"
"specs-create-dir": "mkdir -p templates/api",
"specs": "yarn run specs-create-dir && yarn run specs-build && yarn run specs-validate",
"dev": "yarn run encore dev",
"prod": "yarn run encore production"
},
"dependencies": {
"bootstrap-icons": "^1.11.3"
}
"version": "0.0.0"
}

View File

@ -304,6 +304,27 @@
"config/packages/monolog.yaml"
]
},
"symfony/notifier": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.0",
"ref": "178877daf79d2dbd62129dd03612cb1a2cb407cc"
},
"files": [
"config/packages/notifier.yaml"
]
},
"symfony/ovh-cloud-notifier": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.1",
"ref": "fe2e382c22d60eae9ad54cb22862b1c15291fdf8"
}
},
"symfony/routing": {
"version": "5.4",
"recipe": {
@ -355,6 +376,21 @@
"templates/base.html.twig"
]
},
"symfony/ux-translator": {
"version": "2.23",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.9",
"ref": "bc396565cc4cab95692dd6df810553dc22e352e1"
},
"files": [
"assets/translator.js",
"config/packages/ux_translator.yaml",
"var/translations/configuration.js",
"var/translations/index.js"
]
},
"symfony/validator": {
"version": "5.4",
"recipe": {

View File

@ -1,20 +1,6 @@
{
"extends": "@tsconfig/node14/tsconfig.json",
"extends": "./vendor/chill-project/chill-bundles/ts-config-base.json",
"compilerOptions": {
"lib": [
"es2020",
"dom"
],
"module": "es6",
"moduleResolution": "node",
"isolatedModules": true,
"allowJs": false,
"checkJs": false,
"importHelpers": true,
"allowSyntheticDefaultImports": true,
"types": [
"node"
],
"sourceMap": true
},
"includes": [
@ -25,6 +11,9 @@
],
"exclude": [
"./vendor/chill-project/chill-bundles/tests/*",
"./vendor/chill-project/chill-bundles/docs/*"
"./vendor/chill-project/chill-bundles/docs/*",
"./vendor/chill-project/chill-bundles/assets/translator.ts",
"./vendor/chill-project/chill-bundles/var/*.*"
]
}

View File

@ -15,7 +15,7 @@ async function* getFiles(dir, depth, ignored) {
const res = resolve(dir, dirent.name);
if (dirent.isDirectory()) {
if (depth > 0) {
yield* getFiles(res, depth - 1, ignored);
yield* getFiles(res, depth - 1, ignored);
}
} else if (ignored.includes(res)) {
continue;
@ -85,26 +85,28 @@ async function populateConfig(Encore, chillEntries) {
// export the final configuration
module.exports = (async () => {
// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
// Manually configure the runtime environment if not already configured yet by the "encore" command.
// It's useful when you use tools that rely on webpack.config.js file.
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
// basic encore configuration
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.enableSassLoader()
.enableVueLoader(() => {}, {
version: 3
})
.enableTypeScriptLoader(function (tsConfig){
tsConfig.appendTsSuffixTo = [/\.vue$/];
tsConfig.appendTsxSuffixTo = [/\.vue$/];
// temporary fix for https://github.com/vuejs/vue-loader/issues/1915 and https://github.com/vuejs/core/issues/2855
tsConfig.compilerOptions = {strict: !Encore.isProduction()};
tsConfig.silent = false;
version: 3,
runtimeCompilerBuild: true,
})
.enableTypeScriptLoader(/*function (tsConfig){
tsConfig.appendTsSuffixTo = [/\.vue$/];
tsConfig.appendTsxSuffixTo = [/\.vue$/];
// temporary fix for https://github.com/vuejs/vue-loader/issues/1915 and https://github.com/vuejs/core/issues/2855
tsConfig.compilerOptions = {strict: !Encore.isProduction()};
tsConfig.compilerOptions.paths = {"translator": [resolve(__dirname, "./assets/translator.ts")]};
tsConfig.silent = false;
}*/)
//.enableForkedTypeScriptTypesChecking()
.autoProvidejQuery()
.enableSourceMaps(!Encore.isProduction())
@ -113,40 +115,26 @@ module.exports = (async () => {
.enableVersioning()
.enableSingleRuntimeChunk()
.splitEntryChunks()
// added when upgrading to symfony 5.4
// enables and configure @babel/preset-env polyfills
//.configureBabelPresetEnv((config) => {
// config.useBuiltIns = 'usage';
// config.corejs = '3.23';
//})
//.addLoader({ test: /\.pdf$/, loader: 'file-loader', options: { name: '[name]_[hash].[ext]', outputPath: 'pdf/' } })
;
// populate config with chill entries
let chillEntries = [];
await populateConfig(Encore, chillEntries);
//.addLoader({ test: /\.pdf$/, loader: 'file-loader', options: { name: '[name]_[hash].[ext]', outputPath: 'pdf/' } })
// configure Babel
// .configureBabel((config) => {
// config.plugins.push('@babel/a-babel-plugin');
// })
// enables and configure @babel/preset-env polyfills
// .configureBabelPresetEnv((config) => {
// config.useBuiltIns = 'usage';
// config.corejs = '3.23';
// })
;
// enables Sass/SCSS support
//.enableSassLoader()
Encore.addAliases({
translator: resolve(__dirname, './vendor/chill-project/chill-bundles/assets/translator')
});
// add swagger UI
if (!Encore.isProduction()) {
Encore
.addEntry('swagger', __dirname + '/assets/swagger-ui/index.js')
.addLoader({
test: /\.yaml$/,
type: 'json',
use: [
{ loader: 'json-loader' },
{ loader: 'yaml-loader' }
],
});
}
// populate config with chill entries
let chillEntries = [];
await populateConfig(Encore, chillEntries);
//getting the encore config and appending chill entries
config = Encore.getWebpackConfig();

View File

@ -1994,6 +1994,9 @@
loader-utils "^2.0.0"
schema-utils "^3.0.0"
"@symfony/ux-translator@file:vendor/chill-project/chill-bundles/vendor/symfony/ux-translator/assets":
version "1.0.0"
"@symfony/ux-translator@file:vendor/symfony/ux-translator/assets":
version "1.0.0"