@lang-tag/cli 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # Lang-tag CLI
2
2
 
3
-
4
3
  A professional solution for managing translations in modern JavaScript/TypeScript projects, especially those using component-based architectures. `lang-tag` simplifies internationalization by allowing you to define translation keys directly within the components where they are used. Translations become local, callable function objects with full TypeScript support, IntelliSense, and compile-time safety.
5
4
 
6
5
  ## Key Benefits
@@ -15,7 +14,7 @@ The core is optimized for performance, with a bundle size of just **~1KB** ([che
15
14
 
16
15
  ### Effortless translation structure
17
16
 
18
- Instead of manually managing centralized translation files, `lang-tag` lets you colocate keys within components and automatically organizes them into namespaces based on your project structure. For example, all components in `components/orders` or pages in `pages/order` share the `orders` namespace. You define a simple directory-to-namespace mapping once, and `lang-tag` handles merging and file organization—while you retain full control over how namespaces are merged.
17
+ Instead of manually managing centralized translation files, `lang-tag` lets you colocate keys within components and automatically organizes them into namespaces based on your project structure. For example, all components in `components/orders` or pages in `pages/order` share the `orders` namespace. You define a simple directory-to-namespace mapping once, and `lang-tag` handles merging and file organization—while you retain full control over how namespaces are merged.
19
18
 
20
19
  > Set your rules, then let `lang-tag` do the rest.
21
20
 
@@ -31,6 +30,7 @@ Full functionality is available through an advanced CLI that keeps your applicat
31
30
  ### Practical and Flexible Architecture
32
31
 
33
32
  The solution provides:
33
+
34
34
  - **Framework agnostic** – works with any JavaScript/TypeScript project and integrates easily with libraries like react-i18next
35
35
  - **Library ecosystem support** - create reusable component libraries with embedded lang-tag translations that consuming lang-tag applications can easily import/integrate and override
36
36
  - **Full TypeScript support** - complete type safety with IntelliSense for all translation keys and interpolation parameters
@@ -49,21 +49,24 @@ Instead of maintaining separate translation files and complex key mappings, tran
49
49
  // Component with colocated translations using custom i18n tag
50
50
  import { i18n } from '../utils/i18n';
51
51
 
52
- const translations = i18n({
53
- greeting: 'Welcome {{name}} to our store!',
54
- orderSummary: 'You have {{count}} items in your cart.',
55
- actions: {
56
- proceed: 'Proceed to Payment',
57
- cancel: 'Cancel Order'
52
+ const translations = i18n(
53
+ {
54
+ greeting: 'Welcome {{name}} to our store!',
55
+ orderSummary: 'You have {{count}} items in your cart.',
56
+ actions: {
57
+ proceed: 'Proceed to Payment',
58
+ cancel: 'Cancel Order',
59
+ },
60
+ },
61
+ {
62
+ namespace: 'orders',
63
+ path: 'components.checkout',
58
64
  }
59
- }, {
60
- namespace: 'orders',
61
- path: 'components.checkout'
62
- });
65
+ );
63
66
 
64
67
  function CheckoutComponent({ name, count }) {
65
68
  const t = translations.useT();
66
-
69
+
67
70
  return (
68
71
  <div>
69
72
  <h2>{t.greeting({ name })}</h2>
@@ -82,16 +85,19 @@ function CheckoutComponent({ name, count }) {
82
85
  The `lang-tag` ecosystem provides tooling to transform colocated definitions into production-ready translation files:
83
86
 
84
87
  **Collection & Organization**
88
+
85
89
  - The `lang-tag collect` command discovers translation tags throughout your codebase
86
90
  - Translations are organized into namespace-based JSON files (e.g., `public/locales/en/orders.json`)
87
91
  - Hierarchical key structures can be automatically generated based on configuration rules (eg.: based on component paths)
88
92
 
89
93
  **Dynamic Configuration Management**
94
+
90
95
  - Configuration parameters can be automatically generated using `onConfigGeneration` rules
91
96
  - Namespace and path assignments can be derived from custom logic (eg.: by file structure, component location)
92
97
  - The `lang-tag regenerate-tags` command updates source code configurations dynamically
93
98
 
94
99
  **Development-Time Optimization**
100
+
95
101
  - Watch mode (`lang-tag watch`) provides real-time translation collection during development
96
102
  - Changes to translation definitions trigger automatic regeneration of translation files
97
103
  - Full TypeScript integration ensures compile-time validation of translation keys and parameters
@@ -99,16 +105,19 @@ The `lang-tag` ecosystem provides tooling to transform colocated definitions int
99
105
  ### Enterprise Integration Capabilities
100
106
 
101
107
  **Framework Agnostic Architecture**
108
+
102
109
  - Core library provides building blocks (like `createCallableTranslations`) for creating custom tag functions
103
110
  - Seamless integration with existing i18n libraries (i18next, react-i18next, etc.)
104
111
  - Maintains compatibility with current translation workflows while enhancing developer experience
105
112
 
106
113
  **Library Ecosystem Support**
114
+
107
115
  - Component libraries can embed translations using `.lang-tag.exports.json` manifests
108
116
  - The `lang-tag import` command automatically discovers and integrates library translations
109
117
  - Consuming applications maintain full control over translation overrides and customization
110
118
 
111
119
  **Type-Safe Translation Experience**
120
+
112
121
  - Complete TypeScript support with IntelliSense for all translation keys
113
122
  - Compile-time validation of interpolation parameters
114
123
  - Callable translation objects provide intuitive API with full type inference
@@ -134,4 +143,4 @@ For detailed setup, usage, and advanced features, please refer to the documentat
134
143
  - [React-i18next Example](docs/react-i18n-example.md)
135
144
  - [Library Support](docs/library-support.md)
136
145
  - [API Reference](docs/api-reference.md)
137
- - [Flexible Translation Definitions](docs/flexible-translations.md)
146
+ - [Flexible Translation Definitions](docs/flexible-translations.md)
@@ -1,5 +1,5 @@
1
- import { TranslationsCollector } from './type.ts';
2
- import { LangTagCLIProcessedTag } from '../../config.ts';
1
+ import { TranslationsCollector } from './type';
2
+ import { LangTagCLIProcessedTag } from '../../type';
3
3
  interface Options {
4
4
  appendNamespaceToPath: boolean;
5
5
  }
@@ -5,6 +5,6 @@
5
5
  * during the collection process. Each collector implements a different strategy
6
6
  * for organizing translations (e.g., single dictionary vs. namespace-based files).
7
7
  */
8
- export { DictionaryCollector } from './dictionary-collector.ts';
9
- export { NamespaceCollector } from './namespace-collector.ts';
10
- export { type TranslationsCollector } from './type.ts';
8
+ export { DictionaryCollector } from './dictionary-collector';
9
+ export { NamespaceCollector } from './namespace-collector';
10
+ export { type TranslationsCollector } from './type';
@@ -1,5 +1,5 @@
1
- import { TranslationsCollector } from './type.ts';
2
- import { LangTagCLIProcessedTag } from '../../config.ts';
1
+ import { TranslationsCollector } from './type';
2
+ import { LangTagCLIProcessedTag } from '../../type';
3
3
  export declare class NamespaceCollector extends TranslationsCollector {
4
4
  private clean;
5
5
  private languageDirectory;
@@ -1,5 +1,5 @@
1
- import { LangTagCLIConfig, LangTagCLIProcessedTag } from '../../config.ts';
2
- import { LangTagCLILogger } from '../../logger.ts';
1
+ import { LangTagCLILogger } from '../../logger';
2
+ import { LangTagCLIConfig, LangTagCLIProcessedTag } from '../../type';
3
3
  export declare abstract class TranslationsCollector {
4
4
  config: LangTagCLIConfig;
5
5
  logger: LangTagCLILogger;
@@ -1,4 +1,4 @@
1
- import { LangTagCLIConfigGenerationEvent } from '../../config.ts';
1
+ import { LangTagCLIConfigGenerationEvent } from '../../type';
2
2
  export type ConfigKeeperMode = 'namespace' | 'path' | 'both';
3
3
  export interface ConfigKeeperOptions {
4
4
  /**
@@ -4,6 +4,6 @@
4
4
  * These algorithms customize how translation tag configurations are generated
5
5
  * during collection and regeneration.
6
6
  */
7
- export { pathBasedConfigGenerator, type PathBasedConfigGeneratorOptions } from './path-based-config-generator.ts';
8
- export { configKeeper, type ConfigKeeperOptions, type ConfigKeeperMode } from './config-keeper.ts';
9
- export { prependNamespaceToPath, type PrependNamespaceToPathOptions } from './prepend-namespace-to-path.ts';
7
+ export { pathBasedConfigGenerator, type PathBasedConfigGeneratorOptions, } from './path-based-config-generator';
8
+ export { configKeeper, type ConfigKeeperOptions, type ConfigKeeperMode, } from './config-keeper';
9
+ export { prependNamespaceToPath, type PrependNamespaceToPathOptions, } from './prepend-namespace-to-path';
@@ -1,4 +1,4 @@
1
- import { LangTagCLIConfigGenerationEvent } from '../../config.ts';
1
+ import { LangTagCLIConfigGenerationEvent } from '../../type';
2
2
  import { CaseType } from '../case-utils';
3
3
  export interface PathBasedConfigGeneratorOptions {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { LangTagCLIConfigGenerationEvent } from '../../config.ts';
1
+ import { LangTagCLIConfigGenerationEvent } from '../../type';
2
2
  /**
3
3
  * Options for the prependNamespaceToPath algorithm.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { LangTagCLIImportEvent } from '../../config.ts';
1
+ import { LangTagCLIImportEvent } from '../../type';
2
2
  import { CaseType } from '../case-utils';
3
3
  /**
4
4
  * Available case transformation options for variable names.
@@ -4,5 +4,5 @@
4
4
  * These algorithms customize how library translations are imported
5
5
  * and organized in your project.
6
6
  */
7
- export { flexibleImportAlgorithm, type FlexibleImportAlgorithmOptions, type FilePathCaseType, type VariableNameCaseType } from './flexible-import-algorithm.ts';
8
- export { simpleMappingImportAlgorithm, type SimpleMappingImportAlgorithmOptions, type PackageMapping, type FileMapping } from './simple-mapping-import-algorithm.ts';
7
+ export { flexibleImportAlgorithm, type FlexibleImportAlgorithmOptions, type FilePathCaseType, type VariableNameCaseType, } from './flexible-import-algorithm';
8
+ export { simpleMappingImportAlgorithm, type SimpleMappingImportAlgorithmOptions, type PackageMapping, type FileMapping, } from './simple-mapping-import-algorithm';
@@ -1,4 +1,4 @@
1
- import { LangTagCLIImportEvent } from '../../config.ts';
1
+ import { LangTagCLIImportEvent } from '../../type';
2
2
  /**
3
3
  * Mapping for a specific file within a package.
4
4
  * Defines which variables to import and optionally rename them.