PHPackages                             codemagpie/hyperf-language-package - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. codemagpie/hyperf-language-package

ActiveLibrary[Localization &amp; i18n](/categories/localization)

codemagpie/hyperf-language-package
==================================

1.0.0(2y ago)061MITPHPPHP &gt;=7.4

Since Aug 31Pushed 2y ago1 watchersCompare

[ Source](https://github.com/codemagpie/hyperf-language-package)[ Packagist](https://packagist.org/packages/codemagpie/hyperf-language-package)[ RSS](/packages/codemagpie-hyperf-language-package/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (9)Versions (2)Used By (0)

多语言
===

[](#多语言)

简介
--

[](#简介)

这个包,只适用于hyperf框架,用于多语言的配置,原理是使用包里面的翻译器替换掉hyperf框架子自带的翻译器。

安装
--

[](#安装)

```
composer douyu/hyperf-language-package
```

使用说明
----

[](#使用说明)

### 1.创建表

[](#1创建表)

ps: 请根据自己的需求添加表前缀.

```
-- 创建语言模块配置表
CREATE TABLE `language_module` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
    `parent_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '父级id',
    `name` varchar(100) NOT NULL COMMENT '名称',
    `description` varchar(1000) NOT NULL DEFAULT '' COMMENT '描述',
    `created_at` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `updated_at` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_name` (`name`) COMMENT '名称索引',
    KEY `idx_parent_id` (`parent_id`) COMMENT '父级id索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='多语言模块表';

-- 创建多语言配置表
CREATE TABLE `language_config` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
    `module_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '模块id',
    `entry_name` varchar(100) NOT NULL COMMENT '词条名称',
    `entry_code` varchar(100) NOT NULL COMMENT '词条编码',
    `description` varchar(1000) NOT NULL DEFAULT '' COMMENT '描述',
    `created_at` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `updated_at` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `idx_entry_code` (`entry_code`) COMMENT '词条唯一索引',
    KEY `idx_entry_name` (`entry_name`) COMMENT '词条名称索引',
    KEY `idx_module_id_entry_code` (`module_id`, `entry_code`) COMMENT '模块id和词条编码索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='多语言配置表';

-- 创建多语言翻译表
CREATE TABLE `m_language_translation` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
    `entry_code` varchar(100) NOT NULL COMMENT '词条编码',
    `locale` varchar(10) NOT NULL COMMENT '语言区域',
    `translation` text NULL COMMENT '翻译',
    `created_at` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
    `updated_at` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `idx_entry_code_locale` (`entry_code`, `locale`) COMMENT '词条和语言区域唯一索引',
    KEY `idx_locale` (`locale`) COMMENT '语言索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='多语言翻译表';
```

配置文件说明
------

[](#配置文件说明)

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1083d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/41910202?v=4)[lyf](/maintainers/codemagpie)[@codemagpie](https://github.com/codemagpie)

---

Top Contributors

[![codemagpie](https://avatars.githubusercontent.com/u/41910202?v=4)](https://github.com/codemagpie "codemagpie (50 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/codemagpie-hyperf-language-package/health.svg)

```
[![Health](https://phpackages.com/badges/codemagpie-hyperf-language-package/health.svg)](https://phpackages.com/packages/codemagpie-hyperf-language-package)
```

###  Alternatives

[smarty-gettext/smarty-gettext

Gettext plugin enabling internationalization in Smarty Package files

752.5M8](/packages/smarty-gettext-smarty-gettext)[devaslanphp/auto-translate

Auto generate translation JSON files

6627.3k](/packages/devaslanphp-auto-translate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
