Skip to content

Commit

Permalink
feat(locale): support language en_US, zh_CN
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoukk committed May 13, 2019
1 parent 84608c5 commit a2398e6
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 131 deletions.
8 changes: 4 additions & 4 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,17 +352,17 @@ func (image *KimgImagick) crop(mw *imagick.MagickWand, req *KimgRequest) error {

switch req.Offset {
case "lt":
x += req.OffsetX
y += req.OffsetY
x -= req.OffsetX
y -= req.OffsetY
case "lb":
x -= req.OffsetX
y += req.OffsetY
case "rt":
x += req.OffsetX
y -= req.OffsetY
case "rb":
x -= req.OffsetX
y -= req.OffsetY
x += req.OffsetX
y += req.OffsetY
}

if err := mw.CropImage(uint(req.CropW), uint(req.CropH), x, y); err != nil {
Expand Down
1 change: 1 addition & 0 deletions web/.umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
dynamicImport: { webpackChunkName: true },
title: 'kimg',
dll: true,
locale: {},

routes: {
exclude: [
Expand Down
3 changes: 2 additions & 1 deletion web/src/layouts/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Layout } from 'antd';
import { FormattedMessage } from 'umi-plugin-react/locale';
import pkg from '../../package.json';
import styles from './index.css'

Expand All @@ -9,7 +10,7 @@ function BasicLayout(props) {
return (
<Layout className={styles.page}>
<Header className={styles.header}>
<div className={styles.title}>Welcome to Kimg <span className={styles.version}>v{pkg.version}</span></div>
<div className={styles.title}><FormattedMessage id="WELCOME_TO_KIMG"/> <span className={styles.version}>v{pkg.version}</span></div>
</Header>
<Content className={styles.content}>
{props.children}
Expand Down
77 changes: 77 additions & 0 deletions web/src/locales/en-US.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
export default {
WELCOME_TO_KIMG: 'Welcome to Kimg',
ROTATE: 'Rotate',
BACKGROUND: 'BackGround',
GRAY: 'Gray',
QUALITY: 'Quality',
AUTO_ORIENT: 'AutoOrient',
OUTPUT_FORMAT: 'Format',
STRIP: 'Strip',
TAB_BASIC: 'Basic',
TAB_SCALE: 'Scale',
TAB_CROP: 'Crop',
TAB_WATERMARK: 'Water Mark',
CONVERT_PANEL: 'Convert Panel',
ADMIN_PANEL: 'Admin Panel',
LOAD_IMAGE_BY_MD5: 'Load Image From Kimg By Md5sum',
DELETE_IMAGE_CONFIRM: 'Are you sure delete this image?',
BTN_DELETE: 'DELETE',
BTN_UPLOAD: 'UPLOAD',
TEXT_UPLOAD: 'Click or drag image file to this area to upload',
HINT_UPLOAD: 'Support for a single upload.',
ERR_LOAD_IMAGE: 'load image {md5sum} failed.',
ERR_UPLOAD_IMAGE: '{name} upload failed.',
SUCCESS_UPLOAD_IMAGE: '{name} uploaded successfully.',
SUCCESS_DELETE_IMAGE: 'delete image {md5sum} successfully.',
ERR_DELETE_IMAGE: 'delete image {md5sum} failed.',
ERR_INVALID_IMAGE: 'invalid image md5sum: {md5sum}.',
SIZE: 'Size',
WIDTH: 'Width',
HEIGHT: 'Height',
FORMAT: 'Format',
CROP_ENABLE: 'Crop Enable',
CROP_GRAVITY: 'Crop Gravity',
GRAVITY_NW: 'NW',
GRAVITY_N: 'N',
GRAVITY_NE: 'NE',
GRAVITY_W: 'W',
GRAVITY_C: 'C',
GRAVITY_E: 'E',
GRAVITY_SW: 'SW',
GRAVITY_S: 'S',
GRAVITY_SE: 'SE',
CROP_WIDTH: 'Crop Width',
CROP_HEIGHT: 'Crop Height',
OFFSET_MODE: 'Offset Mode',
OFFSET_X: 'Offset X',
OFFSET_Y: 'Offset Y',
CROP_LT: 'LT',
CROP_LB: 'LB',
CROP_RT: 'RT',
CROP_RB: 'RB',
FORMAT_NONE: 'NONE',
FORMAT_JPG: 'JPG',
FORMAT_PNG: 'PNG',
FORMAT_WEBP: 'WEBP',
FORMAT_GIF: 'GIF',
SCALE_ENABLE: 'Scale Enable',
SCALE_MODE: 'Scale Mode',
SCALE_WIDTH: 'Scale Width',
SCALE_HEIGHT: 'Scale Height',
SCALE_PERCENT: 'Scale Percent',
SCALE_WIDTH_PERCENT: 'Width Percent',
SCALE_HEIGHT_PERCENT: 'Height Percent',
WATERMARK_ENABLE: 'WaterMark Enable',
WATERMARK_TEXT: 'Text',
WATERMARK_LOGO: 'Logo Url',
WATERMARK_FONT_NAME: 'Font Name',
WATERMARK_FONT_SIZE: 'Font Size',
WATERMARK_FONT_COLOR: 'Font Color',
WATERMARK_STROKE_COLOR: 'Stroke Color',
WATERMARK_STROKE_WIDTH: 'Stroke Width',
WATERMARK_GRAVITY: 'Gravity',
WATERMARK_X: 'X',
WATERMARK_Y: 'Y',
WATERMARK_ROTATE: 'Rotate',
WATERMARK_OPACITY: 'Opacity',
}
77 changes: 77 additions & 0 deletions web/src/locales/zh-CN.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
export default {
WELCOME_TO_KIMG: '欢迎光临KIMG',
ROTATE: '旋转角度',
BACKGROUND: '背景色',
GRAY: '灰化',
QUALITY: '图片质量',
AUTO_ORIENT: '自动旋正',
OUTPUT_FORMAT: '输出格式',
STRIP: '瘦身',
TAB_BASIC: '基础设置',
TAB_SCALE: '缩放设置',
TAB_CROP: '裁剪设置',
TAB_WATERMARK: '水印设置',
CONVERT_PANEL: '转换面板',
ADMIN_PANEL: '管理面板',
LOAD_IMAGE_BY_MD5: '通过Md5sum从Kimg服务器中加载图片',
DELETE_IMAGE_CONFIRM: '是否确定删除图片?',
BTN_DELETE: '删除',
BTN_UPLOAD: '上传',
TEXT_UPLOAD: '点击或拖动图片到此区域上传',
HINT_UPLOAD: '支持单个图片上传',
ERR_LOAD_IMAGE: '加载图片 {md5sum} 失败。',
ERR_UPLOAD_IMAGE: '{name} 上传失败。',
SUCCESS_UPLOAD_IMAGE: '{name} 上传成功。',
SUCCESS_DELETE_IMAGE: '删除图片 {md5sum} 成功。',
ERR_DELETE_IMAGE: '删除图片 {md5sum} 失败。',
ERR_INVALID_IMAGE: '无效的图片 md5sum: {md5sum}.',
SIZE: '尺寸',
WIDTH: '宽度',
HEIGHT: '高度',
FORMAT: '格式',
CROP_ENABLE: '开启裁剪',
CROP_GRAVITY: '裁剪原点',
GRAVITY_NW: '左上',
GRAVITY_N: '上',
GRAVITY_NE: '右上',
GRAVITY_W: '左',
GRAVITY_C: '中',
GRAVITY_E: '右',
GRAVITY_SW: '左下',
GRAVITY_S: '下',
GRAVITY_SE: '右上',
CROP_WIDTH: '裁剪宽度',
CROP_HEIGHT: '裁剪高度',
OFFSET_MODE: '偏移模式',
OFFSET_X: '偏移X',
OFFSET_Y: '偏移Y',
CROP_LT: '左上',
CROP_LB: '左下',
CROP_RT: '右上',
CROP_RB: '右下',
FORMAT_NONE: '原图一致',
FORMAT_JPG: 'JPG',
FORMAT_PNG: 'PNG',
FORMAT_WEBP: 'WEBP',
FORMAT_GIF: 'GIF',
SCALE_ENABLE: '开启缩放',
SCALE_MODE: '缩放模式',
SCALE_WIDTH: '缩放宽度',
SCALE_HEIGHT: '缩放高度',
SCALE_PERCENT: '缩放百分比',
SCALE_WIDTH_PERCENT: '宽度缩放百分比',
SCALE_HEIGHT_PERCENT: '高度缩放百分比',
WATERMARK_ENABLE: '开启水印',
WATERMARK_TEXT: '水印文本',
WATERMARK_LOGO: '水印图片',
WATERMARK_FONT_NAME: '字体名称',
WATERMARK_FONT_SIZE: '文字大小',
WATERMARK_FONT_COLOR: '文字颜色',
WATERMARK_STROKE_COLOR: '描边颜色',
WATERMARK_STROKE_WIDTH: '描边宽度',
WATERMARK_GRAVITY: '水印位置',
WATERMARK_X: '边距 X',
WATERMARK_Y: '边距 Y',
WATERMARK_ROTATE: '旋转角度',
WATERMARK_OPACITY: '不透明度',
}
Loading

0 comments on commit a2398e6

Please sign in to comment.