# generaltranslation: General Translation Core SDK: 概要
URL: https://generaltranslation.com/ja/docs/core.mdx
---
title: 概要
description: generaltranslation ライブラリの概要
---
## はじめに
`generaltranslation` ライブラリは、翻訳や書式設定のためのユーティリティ関数やクラスを備えた、GT の中核となる i18n ライブラリです。
`gt-next` や `gt-react` などのフレームワーク向けパッケージと併用されることが多いですが、単体のライブラリとして使用することもできます。
import Video from '@/components/Video';
```typescript title="index.ts"
import { GT } from 'generaltranslation';
const gt = new GT({
apiKey: 'your-api-key',
projectId: 'your-project-id',
sourceLocale: 'en',
targetLocale: 'es',
});
// コンテンツを翻訳する
const result = await gt.translate('Hello, world!', 'es');
// "¡Hola, mundo!"
// 数値、日付、通貨をフォーマットする
const formattedPrice = gt.formatNum(29.99, { style: 'currency', currency: 'USD' });
const formattedDate = gt.formatDateTime(new Date());
// "$29.99"
// "9/25/2025"
// ロケールを操作する
const localeProps = gt.getLocaleProperties('fr-CA');
const isValid = gt.isValidLocale('de');
// { language: "fr", region: "CA", ... }
// true
```
***
## インストール
```bash
npm install generaltranslation
```
```bash
yarn add generaltranslation
```
```bash
bun add generaltranslation
```
```bash
pnpm add generaltranslation
```
***
## 例
翻訳には大きく分けて2種類あります。文字列翻訳とファイル翻訳です。
### セットアップ
翻訳を有効にするには、プロジェクトIDとAPIキーを指定する必要があります。
詳細については、[`constructor`](/docs/core/class/constructor) メソッドを参照してください。
```typescript
const gt = new GT({
apiKey: 'your-api-key',
projectId: 'your-project-id',
targetLocale: 'es',
});
```
### 文字列の翻訳
詳しくは、[`translate`](/docs/core/class/methods/translation/translate) メソッドを参照してください。
```typescript
try {
const result = await gt.translate('Hello, world!');
console.log(result); // "¡Hola, mundo!"
} catch (error) {
console.error('翻訳に失敗しました:', error.message);
}
```
### ファイル翻訳
ファイルはジョブ単位で翻訳されます。
ジョブは、ファイルをアップロードすると開始されます。
複数のファイルをアップロードすると、複数のジョブが開始されます。
詳しくは、[`uploadSourceFiles`](/docs/core/class/methods/translation/upload-source-files)
および [`queryFileData`](/docs/core/class/methods/translation/query-file-data) メソッドを参照してください。
```typescript
// アップロードするファイル
const files = [
{
source: {
fileName: 'src/components/Button.tsx',
fileFormat: 'TSX',
locale: 'en',
content: '...',
},
},
];
// ソースファイルをアップロード
await gt.uploadSourceFiles(files);
```
***
## 目次
### GT クラス
翻訳およびロケール機能の主要クラス:
* **[Constructor](/docs/core/class/constructor)** - 設定を指定して GT インスタンスを初期化します
* **[setConfig](/docs/core/class/set-config)** - GT インスタンスの設定を更新します
#### 翻訳メソッド
* **[translate](/docs/core/class/methods/translation/translate)** - コアの翻訳機能
* **[translateMany](/docs/core/class/methods/translation/translate-many)** - 一括翻訳
* **[setupProject](/docs/core/class/methods/translation/setup-project)** - プロジェクトの初期化
* **[checkJobStatus](/docs/core/class/methods/translation/check-job-status)** - ジョブの進行状況を確認
* **[getProjectData](/docs/core/class/methods/translation/get-project-data)** - プロジェクト情報を取得
* **[uploadSourceFiles](/docs/core/class/methods/translation/upload-source-files)** - 翻訳対象ファイルをアップロード
* **[uploadTranslations](/docs/core/class/methods/translation/upload-translations)** - 既存の翻訳をアップロード
* **[enqueueFiles](/docs/core/class/methods/translation/enqueue-files)** - 処理用キューにファイルを追加
* **[queryFileData](/docs/core/class/methods/translation/query-file-data)** - 翻訳ステータスを確認
* **[downloadFile](/docs/core/class/methods/translation/download-file)** - 単一ファイルをダウンロード
* **[downloadFileBatch](/docs/core/class/methods/translation/download-file-batch)** - 複数ファイルをダウンロード
* **[querySourceFile](/docs/core/class/methods/translation/query-source-file)** - ソースファイル情報を取得
#### 書式設定メソッド
* **[formatMessage](/docs/core/class/methods/formatting/format-message)** - 国際化テキストの書式設定
* **[formatNum](/docs/core/class/methods/formatting/format-num)** - 数値の書式設定
* **[formatDateTime](/docs/core/class/methods/formatting/format-date-time)** - 日時の書式設定
* **[formatRelativeTime](/docs/core/class/methods/formatting/format-relative-time)** - 単位を明示した相対時間の書式設定
* **[formatRelativeTimeFromDate](/docs/core/class/methods/formatting/format-relative-time-from-date)** - Date からの相対時間の書式設定
* **[formatCutoff](/docs/core/class/methods/formatting/format-cutoff)** - テキストの切り詰め書式設定
* **[formatListToParts](/docs/core/class/methods/formatting/format-list-to-parts)** - リストを部分ごとに書式設定
#### ロケールメソッド
* **[getLocaleName](/docs/core/class/methods/locales/get-locale-name)** - ロケールの表示名を取得
* **[getLocaleProperties](/docs/core/class/methods/locales/get-locale-properties)** - ロケールの詳細情報を取得
* **[getLocaleDirection](/docs/core/class/methods/locales/get-locale-direction)** - ロケールのテキスト方向を取得
* **[getLocaleEmoji](/docs/core/class/methods/locales/get-locale-emoji)** - ロケールの国旗絵文字を取得
* **[getRegionProperties](/docs/core/class/methods/locales/get-region-properties)** - 地域の情報とプロパティを取得
* **[isValidLocale](/docs/core/class/methods/locales/is-valid-locale)** - ロケールコードを検証
* **[resolveAliasLocale](/docs/core/class/methods/locales/resolve-alias-locale)** - 標準ロケールをエイリアスロケールに変換
* **[resolveCanonicalLocale](/docs/core/class/methods/locales/resolve-canonical-locale)** - エイリアスロケールを標準ロケール形式に変換
* **[standardizeLocale](/docs/core/class/methods/locales/standardize-locale)** - ロケールコードの形式を標準化
* **[isSameDialect](/docs/core/class/methods/locales/is-same-dialect)** - ロケールが同じ方言を表しているかを確認
* **[isSameLanguage](/docs/core/class/methods/locales/is-same-language)** - ロケールが同じ言語を表しているかを確認
* **[isSupersetLocale](/docs/core/class/methods/locales/is-superset-locale)** - ロケール間の階層関係を確認
* **[determineLocale](/docs/core/class/methods/locales/determine-locale)** - 優先設定から最適なロケールを特定
* **[requiresTranslation](/docs/core/class/methods/locales/requires-translation)** - 翻訳が必要かどうかを判定
### ユーティリティ関数
#### 書式設定関数
* **[formatMessage](/docs/core/functions/formatting/format-message)** - スタンドアロンのテキスト書式設定
* **[formatNum](/docs/core/functions/formatting/format-num)** - スタンドアロンの数値書式設定
* **[formatDateTime](/docs/core/functions/formatting/format-date-time)** - スタンドアロンの日付/時刻書式設定
* **[formatRelativeTime](/docs/core/functions/formatting/format-relative-time)** - スタンドアロンの相対時間書式設定
* **[formatRelativeTimeFromDate](/docs/core/functions/formatting/format-relative-time-from-date)** - Date からのスタンドアロンの相対時間書式設定
* **[formatCutoff](/docs/core/functions/formatting/format-cutoff)** - スタンドアロンのテキスト切り詰め書式設定
* **[formatListToParts](/docs/core/functions/formatting/format-list-to-parts)** - 部分 へのスタンドアロンのリスト書式設定
#### ロケール関数
* **[getLocaleName](/docs/core/functions/locales/get-locale-name)** - スタンドアロンのロケール名ユーティリティ
* **[getLocaleProperties](/docs/core/functions/locales/get-locale-properties)** - スタンドアロンのロケールプロパティ
* **[getLocaleDirection](/docs/core/functions/locales/get-locale-direction)** - スタンドアロンのテキスト方向ユーティリティ
* **[getLocaleEmoji](/docs/core/functions/locales/get-locale-emoji)** - スタンドアロンの絵文字ユーティリティ
* **[getRegionProperties](/docs/core/functions/locales/get-region-properties)** - スタンドアロンの地域プロパティユーティリティ
* **[isValidLocale](/docs/core/functions/locales/is-valid-locale)** - スタンドアロンのロケール検証
* **[resolveAliasLocale](/docs/core/functions/locales/resolve-alias-locale)** - スタンドアロンのエイリアスロケール解決
* **[standardizeLocale](/docs/core/functions/locales/standardize-locale)** - スタンドアロンのロケール標準化
* **[isSameDialect](/docs/core/functions/locales/is-same-dialect)** - スタンドアロンの方言比較
* **[isSameLanguage](/docs/core/functions/locales/is-same-language)** - スタンドアロンの言語比較
* **[isSupersetLocale](/docs/core/functions/locales/is-superset-locale)** - スタンドアロンのロケール階層チェック
* **[determineLocale](/docs/core/functions/locales/determine-locale)** - スタンドアロンのロケールネゴシエーション
* **[requiresTranslation](/docs/core/functions/locales/requires-translation)** - スタンドアロンの翻訳要否チェック
### 型とインターフェース
TypeScript の型定義:
* **[GTConstructorParams](/docs/core/types/gt-constructor-params)** - 設定オプション
* **[LocaleProperties](/docs/core/types/locale-properties)** - ロケールの包括的な情報
* **[TranslationResult](/docs/core/types/translation-result)** - 翻訳レスポンスの型
* **[TranslateManyResult](/docs/core/types/translate-many-result)** - 一括翻訳レスポンス
* **[FileToTranslate](/docs/core/types/file-to-translate)** - ファイル翻訳の設定
* **[EnqueueFilesOptions](/docs/core/types/enqueue-files-options)** - ファイルのキュー追加オプション
* **[Entry](/docs/core/types/Entry)** - 翻訳エントリの構造
* **[EntryMetadata](/docs/core/types/entry-metadata)** - エントリのメタデータ情報
* **[Content](/docs/core/types/Content)** - コンテンツ型の定義
* **[Variable](/docs/core/types/Variable)** - 変数の構造
* **[VariableType](/docs/core/types/variable-type)** - 変数型の定義
* **[JsxElement](/docs/core/types/jsx-element)** - JSX 要素の型
* **[JsxChild](/docs/core/types/jsx-child)** - JSX の子要素の型
* **[JsxChildren](/docs/core/types/jsx-children)** - JSX の子要素群の型
* **[DataFormat](/docs/core/types/data-format)** - データ形式の仕様
* **[CustomMapping](/docs/core/types/custom-mapping)** - カスタムマッピングの設定
***
## 次のステップ
* **[GT クラスの使用を始める](/docs/core/class/constructor)**
* **[翻訳メソッドを確認する](/docs/core/class/methods/translation/translate)**
* **[ロケールユーティリティについて学ぶ](/docs/core/class/methods/locales/get-locale-name)**
* **[書式設定オプションを確認する](/docs/core/class/methods/formatting/format-message)**
* **[スタンドアロン関数を見る](/docs/core/functions/formatting/format-message)**
フレームワーク固有の使い方については、[Next.js](/docs/next) または [React](/docs/react) のドキュメントを参照してください。