65 lines
1.4 KiB
JavaScript
65 lines
1.4 KiB
JavaScript
// app/model/i18n_translation.js
|
|
'use strict';
|
|
|
|
module.exports = app => {
|
|
const { STRING, INTEGER } = app.Sequelize;
|
|
|
|
// 直接在文件中定义常量
|
|
const CONSTANTS = {
|
|
TRANSLATION_STATUS: {
|
|
UNTRANSLATED: 0,
|
|
PENDING_REVIEW: 1,
|
|
APPROVED: 2,
|
|
},
|
|
LANGUAGES: [ 'zh-CN', 'en-US', 'ja-JP' ],
|
|
};
|
|
|
|
const I18nTranslation = app.model.define('wms_i18n_translation', {
|
|
id: {
|
|
type: INTEGER.UNSIGNED,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
},
|
|
key_id: {
|
|
type: INTEGER.UNSIGNED,
|
|
allowNull: false,
|
|
comment: '键ID',
|
|
},
|
|
language: {
|
|
type: STRING(10),
|
|
allowNull: false,
|
|
comment: '语言代码',
|
|
},
|
|
translation: {
|
|
type: STRING(500),
|
|
comment: '翻译内容',
|
|
},
|
|
translation_status: {
|
|
type: INTEGER,
|
|
allowNull: false,
|
|
defaultValue: CONSTANTS.TRANSLATION_STATUS.UNTRANSLATED,
|
|
comment: '翻译状态',
|
|
},
|
|
}, {
|
|
tableName: 'wms_i18n_translations',
|
|
timestamps: true,
|
|
createdAt: 'created_at',
|
|
updatedAt: 'updated_at',
|
|
underscored: true,
|
|
paranoid: false,
|
|
});
|
|
|
|
// 关联关系
|
|
I18nTranslation.associate = function() {
|
|
app.model.I18nTranslation.belongsTo(app.model.I18nKey, {
|
|
foreignKey: 'key_id',
|
|
as: 'key',
|
|
});
|
|
};
|
|
|
|
// 挂载常量到模型(可选)
|
|
I18nTranslation.CONSTANTS = CONSTANTS;
|
|
|
|
return I18nTranslation;
|
|
};
|