(i18nConfig: I18nConfig)
| 43 | }; |
| 44 | |
| 45 | export 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 | |
| 100 | function extractPathPatterns( |
| 101 | sourceLocale: string, |
no test coverage detected