mirror of
https://github.com/elyby/emails-renderer.git
synced 2024-12-22 13:19:45 +05:30
Localization support for images
This commit is contained in:
parent
f1785faa08
commit
fcc5d024cc
@ -13,10 +13,17 @@ export function BitmapText(props) {
|
|||||||
throw new Error('The message.id must be contain 3 parts separated by dots');
|
throw new Error('The message.id must be contain 3 parts separated by dots');
|
||||||
}
|
}
|
||||||
|
|
||||||
const src = require(`emails/${parts[1]}/images/${props.intl.locale}/${parts[2]}.png`);
|
let src;
|
||||||
|
let size;
|
||||||
|
try {
|
||||||
|
src = require(`emails/${parts[1]}/images/${props.intl.locale}/${parts[2]}.png`);
|
||||||
// TODO: we can improve this loader in future by adding an option to disable file emitting
|
// TODO: we can improve this loader in future by adding an option to disable file emitting
|
||||||
// because this thing is handled by url-loader
|
// because this thing is handled by url-loader
|
||||||
const size = require(`image-size!emails/${parts[1]}/images/${props.intl.locale}/${parts[2]}.png`);
|
size = require(`image-size!emails/${parts[1]}/images/${props.intl.locale}/${parts[2]}.png`);
|
||||||
|
} catch (err) { // fallback to default locale
|
||||||
|
src = require(`emails/${parts[1]}/images/${props.intl.defaultLocale}/${parts[2]}.png`);
|
||||||
|
size = require(`image-size!emails/${parts[1]}/images/${props.intl.defaultLocale}/${parts[2]}.png`);
|
||||||
|
}
|
||||||
|
|
||||||
const width = props.retina ? size.width / 2 : size.width;
|
const width = props.retina ? size.width / 2 : size.width;
|
||||||
const height = props.retina ? size.height / 2 : size.height;
|
const height = props.retina ? size.height / 2 : size.height;
|
||||||
@ -26,7 +33,7 @@ export function BitmapText(props) {
|
|||||||
<img src={src} alt={message} style={{
|
<img src={src} alt={message} style={{
|
||||||
width: `${width}px`,
|
width: `${width}px`,
|
||||||
height: `${height}px`,
|
height: `${height}px`,
|
||||||
verticalAlign: 'middle'
|
...props.style
|
||||||
}}/>
|
}}/>
|
||||||
}</Message>
|
}</Message>
|
||||||
);
|
);
|
||||||
@ -39,11 +46,13 @@ BitmapText.propTypes = {
|
|||||||
id: PropTypes.string
|
id: PropTypes.string
|
||||||
})
|
})
|
||||||
]).isRequired,
|
]).isRequired,
|
||||||
|
style: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||||
retina: PropTypes.bool
|
retina: PropTypes.bool
|
||||||
};
|
};
|
||||||
|
|
||||||
BitmapText.defaultProps = {
|
BitmapText.defaultProps = {
|
||||||
retina: true
|
retina: true,
|
||||||
|
style: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
import { injectIntl, intlShape } from 'react-intl';
|
import { injectIntl, intlShape } from 'react-intl';
|
||||||
|
@ -15,13 +15,6 @@ import violetManImage from './images/violetMan.png';
|
|||||||
import orangeManImage from './images/orangeMan.png';
|
import orangeManImage from './images/orangeMan.png';
|
||||||
import darkBlueManImage from './images/darkBlueMan.png';
|
import darkBlueManImage from './images/darkBlueMan.png';
|
||||||
|
|
||||||
import confirmEmailImage from './images/ru/confirmEmail.png';
|
|
||||||
import whatsNextImage from './images/ru/whatsNext.png';
|
|
||||||
import chooseYouSkin from './images/ru/chooseYouSkin.png';
|
|
||||||
import installOurPatch from './images/ru/installOurPatch.png';
|
|
||||||
import useTLauncher from './images/ru/useTlauncher.png';
|
|
||||||
import footerLogoImage from './images/ru/footerLogo.png';
|
|
||||||
|
|
||||||
export default function Register({username, link, code}) {
|
export default function Register({username, link, code}) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -33,7 +26,9 @@ export default function Register({username, link, code}) {
|
|||||||
<Message {...messages.hello_username} values={{username}} />
|
<Message {...messages.hello_username} values={{username}} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<BitmapText message={messages.welcome_image} />
|
<BitmapText message={messages.welcome_image} style={{
|
||||||
|
verticalAlign: 'middle'
|
||||||
|
}} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</Table>
|
</Table>
|
||||||
@ -54,15 +49,9 @@ export default function Register({username, link, code}) {
|
|||||||
}}>
|
}}>
|
||||||
<a href={link}>
|
<a href={link}>
|
||||||
<Button style={styles.confirmEmailButton}>
|
<Button style={styles.confirmEmailButton}>
|
||||||
{/* TODO: текст и картинка */}
|
<BitmapText message={messages.confirm_email_image} style={{
|
||||||
<Message {...messages.confirm_email_image}>{(message) =>
|
|
||||||
<img src={confirmEmailImage} alt={message} style={{
|
|
||||||
width: '147px',
|
|
||||||
// width: '104px',
|
|
||||||
// width: '144px',
|
|
||||||
verticalAlign: 'middle'
|
verticalAlign: 'middle'
|
||||||
}} />
|
}} />
|
||||||
}</Message>
|
|
||||||
</Button>
|
</Button>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@ -96,15 +85,9 @@ export default function Register({username, link, code}) {
|
|||||||
...styles.contentCenterCell,
|
...styles.contentCenterCell,
|
||||||
...styles.whatsNextText
|
...styles.whatsNextText
|
||||||
}}>
|
}}>
|
||||||
{/* TODO: текст и картинка */}
|
<BitmapText message={messages.whats_next_image} style={{
|
||||||
<Message {...messages.whats_next_image}>{(message) =>
|
|
||||||
<img src={whatsNextImage} alt={message} style={{
|
|
||||||
width: '168px',
|
|
||||||
// width: '202px',
|
|
||||||
// width: '154px',
|
|
||||||
verticalAlign: 'middle'
|
verticalAlign: 'middle'
|
||||||
}} />
|
}} />
|
||||||
}</Message>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -118,15 +101,9 @@ export default function Register({username, link, code}) {
|
|||||||
}} />
|
}} />
|
||||||
</td>
|
</td>
|
||||||
<td style={styles.todoItemContent}>
|
<td style={styles.todoItemContent}>
|
||||||
{/* TODO: текст и картинка */}
|
<BitmapText message={messages.choose_you_skin_image} style={{
|
||||||
<Message {...messages.choose_you_skin_image}>{(message) =>
|
|
||||||
<img src={chooseYouSkin} alt={message} style={{
|
|
||||||
width: '179px',
|
|
||||||
// width: '159px',
|
|
||||||
// width: '176px',
|
|
||||||
verticalAlign: 'middle'
|
verticalAlign: 'middle'
|
||||||
}} />
|
}} />
|
||||||
}</Message>
|
|
||||||
<div style={{
|
<div style={{
|
||||||
...styles.paragraph,
|
...styles.paragraph,
|
||||||
...styles.todoItemText
|
...styles.todoItemText
|
||||||
@ -149,15 +126,9 @@ export default function Register({username, link, code}) {
|
|||||||
}} />
|
}} />
|
||||||
</td>
|
</td>
|
||||||
<td style={styles.todoItemContent}>
|
<td style={styles.todoItemContent}>
|
||||||
{/* TODO: текст и картинка */}
|
<BitmapText message={messages.install_our_patch_image} style={{
|
||||||
<Message {...messages.install_our_patch_image}>{(message) =>
|
|
||||||
<img src={installOurPatch} alt={message} style={{
|
|
||||||
width: '252px',
|
|
||||||
// width: '264px',
|
|
||||||
// width: '271px',
|
|
||||||
verticalAlign: 'middle'
|
verticalAlign: 'middle'
|
||||||
}} />
|
}} />
|
||||||
}</Message>
|
|
||||||
<div style={{
|
<div style={{
|
||||||
...styles.paragraph,
|
...styles.paragraph,
|
||||||
...styles.todoItemText
|
...styles.todoItemText
|
||||||
@ -180,15 +151,9 @@ export default function Register({username, link, code}) {
|
|||||||
}} />
|
}} />
|
||||||
</td>
|
</td>
|
||||||
<td style={styles.todoItemContent}>
|
<td style={styles.todoItemContent}>
|
||||||
{/* TODO: текст и картинка */}
|
<BitmapText message={messages.use_tlauncher_image} style={{
|
||||||
<Message {...messages.use_tlauncher_image}>{(message) =>
|
|
||||||
<img src={useTLauncher} alt={message} style={{
|
|
||||||
width: '209px',
|
|
||||||
// width: '138px',
|
|
||||||
// width: '260px',
|
|
||||||
verticalAlign: 'middle'
|
verticalAlign: 'middle'
|
||||||
}} />
|
}} />
|
||||||
}</Message>
|
|
||||||
<div style={{
|
<div style={{
|
||||||
...styles.paragraph,
|
...styles.paragraph,
|
||||||
...styles.todoItemText
|
...styles.todoItemText
|
||||||
@ -215,15 +180,9 @@ export default function Register({username, link, code}) {
|
|||||||
</td>
|
</td>
|
||||||
<td style={styles.footerLogo}>
|
<td style={styles.footerLogo}>
|
||||||
<a href="http://ely.by">
|
<a href="http://ely.by">
|
||||||
{/* TODO: текст и картинка */}
|
<BitmapText message={messages.footer_logo_alt} style={{
|
||||||
<Message {...messages.footer_logo_alt}>{(message) =>
|
|
||||||
<img src={footerLogoImage} alt={message} style={{
|
|
||||||
width: '177px',
|
|
||||||
// width: '139px',
|
|
||||||
// width: '175px',
|
|
||||||
verticalAlign: 'middle'
|
verticalAlign: 'middle'
|
||||||
}} />
|
}} />
|
||||||
}</Message>
|
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB |
Loading…
Reference in New Issue
Block a user