mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-05 03:05:03 +00:00
b99b7f63a0
Since language packs were added, there was a memory leak where each time you load a page containing a translated language, the active language pack would be loaded into memory (RAM) each time, after the initial load. For example, starting the app loads the memory pack into memory first, then if you open settings, it would load the pack twice. Language packs are only a few mb or kb so it wasn't major but it is fixed now.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
const packs = {
|
|
bulgarian: require('./languages/bulgarian'),
|
|
english: require('./languages/english'),
|
|
"french-fr": require('./languages/french-fr'),
|
|
german: require('./languages/german'),
|
|
italian: require('./languages/italian'),
|
|
macedonian: require('./languages/macedonian'),
|
|
malay: require('./languages/malay'),
|
|
dutch: require('./languages/dutch'),
|
|
polish: require('./languages/polish'),
|
|
spanish: require('./languages/spanish'),
|
|
"chinese-traditional": require('./languages/chinese-traditional'),
|
|
"chinese-simplified": require('./languages/chinese-simplified'),
|
|
"brazilian-portuguese": require('./languages/brazilian-portuguese'),
|
|
indonesian: require('./languages/indonesian'),
|
|
}
|
|
|
|
function module(subPack, listPacks) {
|
|
|
|
//--- List All Packs ---//
|
|
if (listPacks === true) return packs;
|
|
|
|
//--- Return Language Pack ---//
|
|
const selectedLanguage = localStorage.getItem("language") || "english";
|
|
const languagePack = packs[selectedLanguage];
|
|
|
|
if (!subPack) return languagePack;
|
|
return languagePack[subPack];
|
|
|
|
}
|
|
|
|
export default ({ app }, inject) => {
|
|
inject("lang", module);
|
|
};
|