Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vocab/types

Package Overview
Dependencies
Maintainers
4
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vocab/types - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

14

CHANGELOG.md
# @vocab/types
## 0.0.5
### Patch Changes
- [`5f5c581`](https://github.com/seek-oss/vocab/commit/5f5c581a65bff28729ee19e1ec0bdea488a9d6c2) [#19](https://github.com/seek-oss/vocab/pull/19) Thanks [@jahredhope](https://github.com/jahredhope)! - Compile useable TypeScript importable files with `vocab compile`.
The new `vocab compile` step replaces `vocab generate-types` in creating a fully functional **translations.ts** file.
This allows vocab to be used **without the Webpack Plugin**, however use of the plugin is still heavily advised to ensure optimal loading of translation content on the web.
Support for unit testing is now better than ever! The newly created **translations.ts** means your unit test code will see the same code as available while rendering.
See the [documentation](https://github.com/seek-oss/vocab) for further usage details.
## 0.0.4

@@ -4,0 +18,0 @@

30

dist/declarations/src/index.d.ts
import type { IntlMessageFormat } from 'intl-messageformat';
export declare type LanguageName = string;
export declare type TranslationKey = string;
export declare type TranslationMessage = string;
export declare type ParsedICUMessages<TranslatedLanguage> = Record<keyof TranslatedLanguage, IntlMessageFormat>;

@@ -7,11 +10,6 @@ export declare type TranslationModule<TranslatedLanguage> = {

};
export declare type TranslationFile<TranslatedLanguage> = {
__DO_NOT_USE__: Record<string, TranslationModule<TranslatedLanguage>>;
};
export interface RawJsonTranslations {
[translationKey: string]: string;
}
export declare type TranslationFile<TranslatedLanguage> = Record<LanguageName, TranslationModule<TranslatedLanguage>>;
export interface LanguageTarget {
name: string;
extends?: string;
name: LanguageName;
extends?: LanguageName;
}

@@ -23,3 +21,3 @@ export interface UserConfig {

*/
devLanguage: string;
devLanguage: LanguageName;
/**

@@ -31,8 +29,10 @@ * An array of languages to build for

}
export declare type LanguageName = string;
export declare type TranslationsByLanguage<Key extends string = string> = Record<Key, {
message: string;
export interface TranslationData {
message: TranslationMessage;
description?: string;
}>;
export declare type LoadedTranslation<Key extends string = string> = {
}
export declare type TranslationsByKey<Key extends TranslationKey = string> = Record<Key, TranslationData>;
export declare type TranslationMessagesByKey<Key extends TranslationKey = string> = Record<Key, TranslationMessage>;
export declare type TranslationsByLanguage<Key extends TranslationKey = string> = Record<LanguageName, TranslationsByKey<Key>>;
export declare type LoadedTranslation<Key extends TranslationKey = string> = {
namespace: string;

@@ -42,3 +42,3 @@ keys: Array<Key>;

relativePath: string;
languages: Map<LanguageName, TranslationsByLanguage<Key>>;
languages: TranslationsByLanguage<Key>;
};
{
"name": "@vocab/types",
"version": "0.0.4",
"version": "0.0.5",
"main": "dist/vocab-types.cjs.js",

@@ -5,0 +5,0 @@ "module": "dist/vocab-types.esm.js",

@@ -71,4 +71,6 @@ # Vocab

**./translations.json**
**Note:** Currently, to create a new translation it must be placed inside a **`__translations__`** folder, this folder name can be configured with `translationsDirname` configuration.
**`./__translations__/translations.json`**
```json

@@ -83,2 +85,5 @@ {

Then run `vocab compile`. Or `vocab compile --watch`.
This will create new `translation.ts` files for each `translation.json` file.
You can then import these translations into your React components. Translations can be used by calling the `t` function returned by `useTranslation`.

@@ -90,3 +95,3 @@

import { useTranslation } from '@vocab/react';
import translations from './translations.json';
import translations from './translations';

@@ -156,3 +161,3 @@ function MyComponent({ children }) {

Vocab generates custom `translation.json.d.ts` files that give your React components strongly typed translations to work with.
Vocab generates custom `translation.ts` files that give your React components strongly typed translations to work with.

@@ -162,5 +167,11 @@ To generate these types run:

```bash
$ vocab generate-types
$ vocab compile
```
Or to rerun the compiler when files change use:
```bash
$ vocab compile --watch
```
## External translation tooling

@@ -167,0 +178,0 @@

import type { IntlMessageFormat } from 'intl-messageformat';
export type LanguageName = string;
export type TranslationKey = string;
export type TranslationMessage = string;
export type ParsedICUMessages<TranslatedLanguage> = Record<

@@ -13,15 +18,12 @@ keyof TranslatedLanguage,

export type TranslationFile<TranslatedLanguage> = {
__DO_NOT_USE__: Record<string, TranslationModule<TranslatedLanguage>>;
};
export type TranslationFile<TranslatedLanguage> = Record<
LanguageName,
TranslationModule<TranslatedLanguage>
>;
export interface RawJsonTranslations {
[translationKey: string]: string;
}
export interface LanguageTarget {
// The name or tag of a language
name: string;
name: LanguageName;
// Translations will be copied from parent language when they don't exist in child. Defaults to first language.
extends?: string;
extends?: LanguageName;
}

@@ -34,3 +36,3 @@

*/
devLanguage: string;
devLanguage: LanguageName;
/**

@@ -42,14 +44,19 @@ * An array of languages to build for

}
export type LanguageName = string;
export type TranslationsByLanguage<Key extends string = string> = Record<
export interface TranslationData {
message: TranslationMessage;
description?: string;
}
export type TranslationsByKey<Key extends TranslationKey = string> = Record<
Key,
{
message: string;
description?: string;
}
TranslationData
>;
export type TranslationMessagesByKey<
Key extends TranslationKey = string
> = Record<Key, TranslationMessage>;
export type LoadedTranslation<Key extends string = string> = {
export type TranslationsByLanguage<
Key extends TranslationKey = string
> = Record<LanguageName, TranslationsByKey<Key>>;
export type LoadedTranslation<Key extends TranslationKey = string> = {
namespace: string;

@@ -59,3 +66,3 @@ keys: Array<Key>;

relativePath: string;
languages: Map<LanguageName, TranslationsByLanguage<Key>>;
languages: TranslationsByLanguage<Key>;
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc