MCPcopy
hub / github.com/lingodotdev/lingo.dev / getBuckets

Function getBuckets

packages/cli/src/cli/utils/buckets.ts:45–98  ·  view source on GitHub ↗
(i18nConfig: I18nConfig)

Source from the content-addressed store, hash-verified

43};
44
45export function getBuckets(i18nConfig: I18nConfig) {
46 const result = Object.entries(i18nConfig.buckets).map(
47 ([bucketType, bucketEntry]) => {
48 const includeItems = bucketEntry.include.map((item) =>
49 resolveBucketItem(item),
50 );
51 const excludeItems = bucketEntry.exclude?.map((item) =>
52 resolveBucketItem(item),
53 );
54 const config: BucketConfig = {
55 type: bucketType as Z.infer<typeof bucketTypeSchema>,
56 paths: extractPathPatterns(
57 i18nConfig.locale.source,
58 includeItems,
59 excludeItems,
60 ),
61 };
62 if (bucketEntry.injectLocale) {
63 config.injectLocale = bucketEntry.injectLocale;
64 }
65 if (bucketEntry.lockedKeys) {
66 config.lockedKeys = bucketEntry.lockedKeys;
67 }
68 if (bucketEntry.lockedPatterns) {
69 config.lockedPatterns = bucketEntry.lockedPatterns;
70 }
71 if (bucketEntry.ignoredKeys) {
72 config.ignoredKeys = bucketEntry.ignoredKeys;
73 }
74 if (bucketEntry.preservedKeys) {
75 config.preservedKeys = bucketEntry.preservedKeys;
76 }
77 if (bucketEntry.localizableKeys) {
78 config.localizableKeys = bucketEntry.localizableKeys;
79 }
80 if (bucketEntry.keyColumn) {
81 if (bucketType !== "csv") {
82 if (!warnedKeyColumnTypes.has(bucketType)) {
83 warnedKeyColumnTypes.add(bucketType);
84 console.warn(
85 `Warning: "keyColumn" is only supported on "csv" buckets, but was set on "${bucketType}". ` +
86 `The setting will be ignored. Remove it from this bucket's config to silence this warning.`,
87 );
88 }
89 } else {
90 config.keyColumn = bucketEntry.keyColumn;
91 }
92 }
93 return config;
94 },
95 );
96
97 return result;
98}
99
100function extractPathPatterns(
101 sourceLocale: string,

Callers 13

buckets.spec.tsFile · 0.90
status.tsFile · 0.90
purge.tsFile · 0.90
lockfile.tsFile · 0.90
i18n.tsFile · 0.90
cleanup.tsFile · 0.90
files.tsFile · 0.90
preserved-keys.tsFile · 0.90
ignored-keys.tsFile · 0.90
locked-keys.tsFile · 0.90
getWatchPatternsFunction · 0.90
planFunction · 0.90

Calls 4

resolveBucketItemFunction · 0.85
extractPathPatternsFunction · 0.85
warnMethod · 0.80
hasMethod · 0.65

Tested by

no test coverage detected