Skip to content

Commit 95f9d6a

Browse files
committed
update packages; add i18n usage
1 parent e832757 commit 95f9d6a

File tree

10 files changed

+582
-414
lines changed

10 files changed

+582
-414
lines changed

data-lib/Cargo.lock

Lines changed: 101 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data-lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2024"
66
[dependencies]
77
chrono = "0.4.41"
88
chumsky = {version = "0.10.1", features = ["unstable"]}
9-
hashbrown = {version = "0.15.3", features = ["serde"]}
9+
hashbrown = {version = "0.16.0", features = ["serde"]}
1010
js-sys = "0.3.77"
1111
rayon = "1.10.0"
1212
regex = "1.11.1"

data-lib/src/common.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,38 @@ pub const FILE_EXT_INCLUDED: &[&str] = &[
4040
"py", "rs", "java", "kt", "rb", "c", "cpp", "h", "hpp",
4141
];
4242

43+
// list of i18n adjacent libraries, thanks chatgpt
44+
pub const I18N_DEPENDENCIES: &[&str] = &[
45+
"i18next",
46+
"i18n",
47+
"node-polyglot",
48+
"formatjs",
49+
"intl-messageformat",
50+
"intl-relativeformat",
51+
"messageformat",
52+
"react-intl",
53+
"react-i18next",
54+
"next-i18next",
55+
"next-intl",
56+
"@lingui/core",
57+
"@lingui/react",
58+
"vue-i18n",
59+
"vue-i18next",
60+
"@ngx-translate/core",
61+
"@angular/localize",
62+
"react-native-localize",
63+
"expo-localization",
64+
"svelte-i18n",
65+
"intl",
66+
"globalize",
67+
];
68+
69+
pub const I18N_LOCALE_CODES: &[&str] = &[
70+
"af", "ar", "bg", "bn", "ca", "cs", "cy", "da", "de", "el", "en", "es", "et", "fa", "fi",
71+
"fr", "he", "hi", "hr", "hu", "id", "it", "ja", "ka", "ko", "lt", "lv", "ms", "nb", "nl",
72+
"pl", "pt", "ro", "ru", "sk", "sl", "sr", "sv", "th", "tr", "uk", "vi", "zh",
73+
];
74+
4375
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4476
pub struct EntryChange {
4577
pub property: String,

data-lib/src/plugin/data_array.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ use wasm_bindgen::prelude::wasm_bindgen;
44

55
use crate::{
66
common::{
7-
CountMonthlyDataPoint, DownloadDataPoint, FILE_EXT_INCLUDED, HallOfFameDataPoint,
8-
InactivityByReleaseDataPoint, IndividualDownloadDataPoint, LOC_EXCLUDED, OverviewDataPoint,
9-
RemovedByReleaseDataPoint, increment_named_data_points, to_percentage,
7+
increment_named_data_points, to_percentage, CountMonthlyDataPoint, DownloadDataPoint, HallOfFameDataPoint, InactivityByReleaseDataPoint, IndividualDownloadDataPoint, OverviewDataPoint, RemovedByReleaseDataPoint, FILE_EXT_INCLUDED, I18N_DEPENDENCIES, LOC_EXCLUDED
108
},
119
date::Date,
1210
license::Licenses,
1311
plugin::{
14-
LicenseInfo, NamedDataPoint, PluginData, PluginExtraData, PluginLicenseDataPoints,
15-
PluginRepoDataPoints, full::FullPluginData,
12+
full::FullPluginData, LicenseInfo, NamedDataPoint, PluginData, PluginExtraData, PluginLicenseDataPoints, PluginRepoDataPoints
1613
},
1714
};
1815

@@ -758,6 +755,20 @@ impl PluginDataArrayView {
758755
tmp.sort_by(|a, b| b.cmp(a));
759756
tmp
760757
}
758+
759+
pub fn i18n_usage(&self, data: &PluginDataArray) -> Vec<String> {
760+
let mut plugins_with_i18n = Vec::new();
761+
762+
self.data.iter().for_each(|&index| {
763+
let plugin_data = &data[index];
764+
765+
if I18N_DEPENDENCIES.iter().any(|dep| plugin_data.has_dependency(dep).unwrap_or(false)) {
766+
plugins_with_i18n.push(plugin_data.id());
767+
}
768+
});
769+
770+
plugins_with_i18n
771+
}
761772
}
762773

763774
#[wasm_bindgen]

data-lib/src/plugin/full.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@ impl FullPluginData {
297297
})
298298
}
299299

300+
pub fn has_dependency(&self, dependency: &str) -> Option<bool> {
301+
self.repo_data().map(|r| {
302+
r.dependencies.iter().any(|d| d == dependency)
303+
|| r.dev_dependencies.iter().any(|d| d == dependency)
304+
})
305+
}
306+
300307
pub fn download_count(&self) -> u32 {
301308
self.data.download_count
302309
}

0 commit comments

Comments
 (0)