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

pkp/pkp-lib#9707 use weblate locales for ui #10569

Merged
merged 12 commits into from
Dec 11, 2024
Merged

pkp/pkp-lib#9707 use weblate locales for ui #10569

merged 12 commits into from
Dec 11, 2024

Conversation

bozana
Copy link
Collaborator

@bozana bozana commented Oct 29, 2024

s. #9707

@bozana bozana force-pushed the 9707 branch 3 times, most recently from 8fb9c58 to 7610a26 Compare November 19, 2024 12:43
{
return $this->weblateLocaleNames ??= (function (): array {
$file = Core::getBaseDir() . '/' . PKP_LIB_PATH . '/lib/weblateLanguages/languages.json';
$key = __METHOD__ . self::MAX_SUBMISSION_LOCALES_CACHE_LIFETIME . filemtime($file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How likely is this file to change? The current value is 1 year.

Suggested change
$key = __METHOD__ . self::MAX_SUBMISSION_LOCALES_CACHE_LIFETIME . filemtime($file);
$key = __METHOD__ . static::MAX_WEBLATE_LOCALES_CACHE_LIFETIME. filemtime($file);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file comes with the installation/upgrade. I suppose then (at installation or upgrade) also the cache will be cleared?
I do not think the users will get it in between.
What would you then suggest the lifetime to be?

];

$schemaLocName = (DB::connection() instanceof PostgresConnection) ? 'TABLE_CATALOG' : 'TABLE_SCHEMA';
$renameLocale = fn (string $l) => collect(DB::select("SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = ? AND {$schemaLocName} = ?", [$l, DB::connection()->getDatabaseName()]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to use the Laravel syntax here (e.g. DB::table()), it will already return a collection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think it's possible to retrieve the metadata using the Laravel stuff (e.g. DB::connection()->getSchemaBuilder()->getTables()), just sounds more flexible than writing custom queries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know how to get tables with locale column using Laravel, so I left this as it is...

@bozana bozana force-pushed the 9707 branch 2 times, most recently from 0feccb0 to 7ed8ea3 Compare December 10, 2024 13:50
@bozana bozana merged commit 0055c0e into pkp:main Dec 11, 2024
1 check passed
@bozana bozana deleted the 9707 branch December 11, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants