Skip to content
Merged
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
24 changes: 24 additions & 0 deletions .gettext.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// eslint-disable-next-line no-undef
module.exports = {
input: {
path: "js",
include: ["**/*.vue"],
parserOptions: {
overrideDefaultKeywords: true,
mapping: {
simple: ["__"],
plural: ["_n"],
ctxPlural: ["_nx"],
ctx: ["_x"]
}
}
},
output: {
path: "./",
potPath: "locales/vue.pot",
locales: [],
splitJson: false,
linguas: false,
flat: true
},
};
4 changes: 2 additions & 2 deletions .github/actions/lint_misc-lint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e -u -x -o pipefail

vendor/bin/licence-headers-check --ansi --no-interaction
bin/console tools:licence_headers_check

vendor/bin/extract-locales 2>&1 | tee extract.log
bin/console tools:locales:extract 2>&1 | tee extract.log
if [[ -n $(grep "warning" extract.log) ]]; then exit 1; fi
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,23 @@ vendor: console
.PHONY: vendor

locales-extract: ## Extract locales
@$(PHP) vendor/bin/extract-locales
@$(CONSOLE) tools:locales:extract
.PHONY: locales-extract

locales-compile: c=locales:compile ## Compile locales
locales-compile: console
locales-compile:
@$(CONSOLE) tools:locales:compile
.PHONY: locales-compile

cc: c=cache:clear ## Clear the cache
cc: console
.PHONY: cc

license-headers-check: ## Verify that the license headers is present all files
@$(PHP) vendor/bin/licence-headers-check
@$(CONSOLE) tools:licence_headers_check
.PHONY: license-headers-check

license-headers-fix: ## Add the missing license headers in all files
@$(PHP) vendor/bin/licence-headers-check --fix
@$(CONSOLE) tools:licence_headers_check --fix
.PHONY: license-headers-fix

## —— Database —————————————————————————————————————————————————————————————————
Expand Down
13 changes: 9 additions & 4 deletions PluginsMakefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,25 @@ test-setup: ## Setup the plugin for tests
.PHONY: test-setup

locales-extract: ## Extract locales
@$(PLUGIN) vendor/bin/extract-locales
@$(CONSOLE) tools:locales:extract --plugin=$(PLUGIN_DIR)
.PHONY: locales-extract

locales-compile: ## Compile locales
@$(PLUGIN) vendor/bin/plugin-release --compile-mo
@$(CONSOLE) tools:locales:compile --plugin=$(PLUGIN_DIR)
.PHONY: locales-compile

plugin-release: ## Build and create plugin release based on HEAD ref, example: make plugin-release
@$(CONSOLE) tools:plugin:release --plugin=$(PLUGIN_DIR) --dest=/var/www/glpi/plugins/$(PLUGIN_DIR)/dist/glpi-$(PLUGIN_DIR)-$(shell date +%Y%m%d).tar.bz2
.PHONY: plugin-release


##—— Licenses —————————————————————————————————————————————————————————————————
license-headers-check: ## Verify that the license headers is present all files
@$(PLUGIN) vendor/bin/licence-headers-check
@$(CONSOLE) tools:licence_headers_check --plugin=$(PLUGIN_DIR)
.PHONY: license-headers-check

license-headers-fix: ## Add the missing license headers in all files
@$(PLUGIN) vendor/bin/licence-headers-check --fix
@$(CONSOLE) tools:licence_headers_check --fix --plugin=$(PLUGIN_DIR)
.PHONY: license-headers-fix

##—— Dependencies ——————————————————————————————————————————————————————————————
Expand Down
40 changes: 10 additions & 30 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ if (isset($_SERVER['argv'])) {
$chunks[0] = preg_replace('/^--/', '', $chunks[0]);
$options[$chunks[0]] = (isset($chunks[1]) ? $chunks[1] : true);
}

// Alias of previous locales compile command
// FIXME: remove in a later GLPI version
if (count($_SERVER['argv']) > 1 && $_SERVER['argv'][1] === 'locales:compile') {
$_SERVER['argv'][1] = 'tools:locales:compile';
}
}

//Handle specific dependencies update command that cannot be made upon symfony console
Expand All @@ -67,10 +73,6 @@ if (isset($_SERVER['argv']) && ['dependencies', 'install'] === array_slice($_SER
exit($exit_code);
}

$exit_code = compileLocales();
if ($exit_code > 0) {
exit($exit_code);
}

$npm_command = 'npm install --no-save';
passthru($npm_command, $exit_code);
Expand All @@ -83,34 +85,12 @@ if (isset($_SERVER['argv']) && ['dependencies', 'install'] === array_slice($_SER
exit($exit_code);
}

exit($exit_code);
}

// Handle specific "locales:compile" command that cannot be made upon symfony console
if (isset($_SERVER['argv']) && ($_SERVER['argv'][1] ?? '') === 'locales:compile') {
$exit_code = compileLocales();

exit($exit_code);
}

function compileLocales(): int
{
chdir(dirname(__FILE__, 2));

$exit_code = 0;

$po_files = preg_grep('/\.po$/', scandir('./locales'));
echo "Compiling MO files...";
foreach ($po_files as $po_file) {
$mo_file = preg_replace('/\.po$/', '.mo', $po_file);
passthru("cd ./locales && msgfmt -f -o {$mo_file} {$po_file}", $exit_code);
if ($exit_code > 0) {
exit($exit_code);
}
passthru('bin/console tools:locales:compile --allow-superuser', $exit_code);
if ($exit_code > 0) {
exit($exit_code);
}
echo " Done.\n";

return $exit_code;
exit($exit_code);
}

// Check the resources state before trying to instanciate the Kernel.
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
"friendsofphp/php-cs-fixer": "^3.86",
"friendsoftwig/twigcs": "^6.5",
"glpi-project/phpstan-glpi": "^1.1",
"glpi-project/tools": "^0.8.3",
"mikey179/vfsstream": "^1.6",
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpstan/phpstan": "^2.1",
Expand All @@ -122,7 +121,9 @@
"shipmonk/composer-dependency-analyser": "^1.8",
"symfony/browser-kit": "^6.4",
"symfony/debug-bundle": "^6.4",
"symfony/finder": "^6.4",
"symfony/http-client": "^6.4",
"symfony/process": "^6.4",
"symfony/stopwatch": "^6.4",
"symfony/twig-bundle": "^6.4",
"symfony/var-dumper": "^6.4",
Expand Down
90 changes: 17 additions & 73 deletions composer.lock

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

Loading