spreed
spreed copied to clipboard
fix(l10n): directly import translate functions to the components
☑️ Resolves
- Required for #12362
Scripted with:
<?php
function injectStrings($directory) {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory),
RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $file) {
if ($file->isFile()) {
$filePath = $file->getPathname();
$contents = file_get_contents($filePath);
if (strpos($contents, "t('spreed'") !== false && strpos($contents, "from '@nextcloud/l10n'") === false) {
$newContents = preg_replace(
'/<script>/',
"<script>\nimport { t } from '@nextcloud/l10n'",
$contents
);
$newContents = preg_replace(
'/methods:\s*\{/',
"methods: {\n t,",
$newContents
);
file_put_contents($filePath, $newContents);
echo "Injected strings in $filePath\n";
}
}
}
}
// Example usage
injectStrings('.');
?>
🖌️ UI Checklist
🚧 Tasks
- [ ] ...
🏁 Checklist
- [ ] 🌏 Tested with Chrome, Firefox and Safari or should not be risky to browser differences
- [ ] 🖥️ Tested with Desktop client or should not be risky for it
- [ ] 🖌️ Design was reviewed, approved or inspired by the design team
- [ ] ⛑️ Tests are included or not possible
- [ ] 📗 User documentation in https://github.com/nextcloud/documentation/tree/master/user_manual/talk has been updated or is not required
Shall we do it in main?
Shall we do it in
main?
There's a lot of files conflicts, so I'd keep it as a next version, what do you think?
For history, using global t wasn't good because:
- It's indeterminate. There is no guarantee,
window.tis the same version as installed@nextcloud/l10n. Different modules may use different versions. Same withVue.prototype.tin Vue 2. - No way to check if in this context
tis defined. Either error from ESLint/TS everywhere, or missing actual errors. We have problems from that in@nextcloud/vuetime to time