---
title: "言語ファイル（.po）の msgctxt と間違いやすい点"
description: "アドオンの .po ファイルで使う msgctxt のプレフィックス一覧と、書き間違えやすい例。"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cs-cart.jp/llms.txt
> Use this file to discover all available pages before exploring further.

# 言語ファイル（.po）の msgctxt と間違いやすい点

アドオンの言語ファイルは、`var/langs/ja/addons/<アドオンID>.po` に置きます。基本的な仕組みは [.poファイルによる言語ファイルの作成](/addon-development/languages-and-translations-by-po-file/) を参照してください。ここでは、`msgctxt` の使い分けと、間違いやすい点をまとめます。

## ヘッダー

```po
msgid ""
msgstr ""
"Project-Id-Version: cs-cart-latest\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language-Team: Japanese\n"
"Language: ja_JP\n"
```

## msgctxt のプレフィックス一覧

| プレフィックス | 用途 |
| --- | --- |
| `Addons::name::` | アドオン名 |
| `Addons::description::` | アドオンの説明 |
| `SettingsSections::` | 設定のセクション |
| `SettingsOptions::` | 設定のオプション |
| `SettingsTooltips::` | 設定オプションのツールチップ |
| `SettingsVariants::` | 設定オプションの選択肢 |
| `Languages::` | 上記以外の一般の言語変数 |

## 形式

```po
# アドオン名・説明（必須）
msgctxt "Addons::name::my_addon"
msgid "My Addon"
msgstr "マイアドオン"

msgctxt "Addons::description::my_addon"
msgid "Addon description"
msgstr "アドオンの説明"

# 設定のセクション
msgctxt "SettingsSections::my_addon::general"
msgid "General"
msgstr "一般"

# 設定のオプション
msgctxt "SettingsOptions::my_addon::option_id"
msgid "Option label"
msgstr "オプションのラベル"

# 設定オプションのツールチップ
msgctxt "SettingsTooltips::my_addon::option_id"
msgid "Tooltip text"
msgstr "ツールチップのテキスト"

# 設定オプションの選択肢
msgctxt "SettingsVariants::my_addon::option_id::variant_id"
msgid "Variant label"
msgstr "選択肢のラベル"

# 一般の言語変数
msgctxt "Languages::my_addon.some_key"
msgid "Text"
msgstr "テキスト"
```

## アドオン固有の言語変数の名前

一般の言語変数は、ほかのアドオンやコアの変数と名前が衝突しないようにします。次のどちらかの形にすると整理しやすくなります。

* アドオンIDとドット区切り：`Languages::my_addon.some_key`
* アドオンの略称とアンダースコア：`Languages::my_addon_some_key`（略称の例：`my_vendor_refunds` に対する `mvr_`）

.po ファイルの中は、コメントで「Settings」「Menu items」「Notifications」のように区切ると読みやすくなります。

## よくある間違い

> **アドオン名に Languages を使わない**
>
> アドオン名は `Addons::name::` で定義します。`Languages::` では定義しません。
>
> ```po
> # 間違い
> msgctxt "Languages::my_addon"
> msgid "my_addon"
> msgstr "マイアドオン"
>
> # 正しい
> msgctxt "Addons::name::my_addon"
> msgid "My Addon"
> msgstr "マイアドオン"
> ```

> **ツールチップに SettingsOptions を使わない**
>
> 設定オプションのツールチップは `SettingsTooltips::` で定義します。
>
> ```po
> # 間違い
> msgctxt "SettingsOptions::my_addon::option_tooltip"
>
> # 正しい
> msgctxt "SettingsTooltips::my_addon::option_id"
> ```

## 関連ページ

* [.poファイルによる言語ファイルの作成](/addon-development/languages-and-translations-by-po-file/)
* [アドオンの言語変数](/addon-development/language-variables-in-addon/)
* [addon.xml の必須要素](/addon-development/tips/addon-xml-required-elements/)
* [管理画面とショップフロントのテンプレートの違い](/addon-development/tips/backend-and-storefront-templates/)（HTML の `<title>` に使う言語変数）

Source: https://docs.cs-cart.jp/addon-development/tips/po-file-msgctxt/index.mdx
