Merge pull request #575 from dcsjapan/admin-string-extraction

This commit is contained in:
Toby Zerner 2015-10-14 14:43:45 +10:30
commit 3ca601d2a5
11 changed files with 85 additions and 81 deletions

View File

@ -35,36 +35,36 @@ export default class AdminNav extends Component {
items.add('dashboard', AdminLinkButton.component({
href: app.route('dashboard'),
icon: 'bar-chart',
children: 'Dashboard',
description: 'Your forum at a glance.'
children: app.trans('core.admin.nav_dashboard_button'),
description: app.trans('core.admin.nav_dashboard_text')
}));
items.add('basics', AdminLinkButton.component({
href: app.route('basics'),
icon: 'pencil',
children: 'Basics',
description: 'Set your forum title, language, and other basic settings.'
children: app.trans('core.admin.nav_basics_button'),
description: app.trans('core.admin.nav_basics_text')
}));
items.add('permissions', AdminLinkButton.component({
href: app.route('permissions'),
icon: 'key',
children: 'Permissions',
description: 'Configure who can see and do what.'
children: app.trans('core.admin.nav_permissions_button'),
description: app.trans('core.admin.nav_permissions_text')
}));
items.add('appearance', AdminLinkButton.component({
href: app.route('appearance'),
icon: 'paint-brush',
children: 'Appearance',
description: 'Customize your forum\'s colors, logos, and other variables.'
children: app.trans('core.admin.nav_appearance_button'),
description: app.trans('core.admin.nav_appearance_text')
}));
items.add('extensions', AdminLinkButton.component({
href: app.route('extensions'),
icon: 'puzzle-piece',
children: 'Extensions',
description: 'Add extra functionality to your forum and make it your own.'
children: app.trans('core.admin.nav_extensions_button'),
description: app.trans('core.admin.nav_extensions_text')
}));
return items;

View File

@ -18,9 +18,9 @@ export default class AppearancePage extends Component {
<div className="container">
<form onsubmit={this.onsubmit.bind(this)}>
<fieldset className="AppearancePage-colors">
<legend>Colors</legend>
<legend>{app.trans('core.admin.appearance_colors_heading')}</legend>
<div className="helpText">
Choose two colors to theme your forum with. The first will be used as a highlight color, while the second will be used to style background elements.
{app.trans('core.admin.appearance_colors_text')}
</div>
<div className="AppearancePage-colors-input">
@ -30,33 +30,33 @@ export default class AppearancePage extends Component {
{Switch.component({
state: this.darkMode(),
children: 'Dark Mode',
children: app.trans('core.admin.appearance_dark_mode_label'),
onchange: this.darkMode
})}
{Switch.component({
state: this.coloredHeader(),
children: 'Colored Header',
children: app.trans('core.admin.appearance_colored_header_label'),
onchange: this.coloredHeader
})}
{Button.component({
className: 'Button Button--primary',
type: 'submit',
children: 'Save Changes',
children: app.trans('core.admin.appearance_submit_button'),
loading: this.loading
})}
</fieldset>
</form>
<fieldset>
<legend>Custom Styles</legend>
<legend>{app.trans('core.admin.appearance_custom_styles_heading')}</legend>
<div className="helpText">
Customize your forum's appearance by adding your own LESS/CSS code to be applied on top of Flarum's default styles.
{app.trans('core.admin.appearance_custom_styles_text')}
</div>
{Button.component({
className: 'Button',
children: 'Edit Custom CSS',
children: app.trans('core.admin.appearance_edit_css_button'),
onclick: () => app.modal.show(new EditCustomCssModal())
})}
</fieldset>
@ -71,7 +71,7 @@ export default class AppearancePage extends Component {
const hex = /^#[0-9a-f]{3}([0-9a-f]{3})?$/i;
if (!hex.test(this.primaryColor()) || !hex.test(this.secondaryColor())) {
alert('Please enter a hexadecimal color code.');
alert(app.trans('core.admin.appearance_enter_hex_message'));
return;
}

View File

@ -36,17 +36,17 @@ export default class BasicsPage extends Component {
<div className="container">
<form onsubmit={this.onsubmit.bind(this)}>
{FieldSet.component({
label: 'Forum Title',
label: app.trans('core.admin.basics_forum_title_heading'),
children: [
<input className="FormControl" value={this.values.forum_title()} oninput={m.withAttr('value', this.values.forum_title)}/>
]
})}
{FieldSet.component({
label: 'Forum Description',
label: app.trans('core.admin.basics_forum_description_heading'),
children: [
<div className="helpText">
Enter a short sentence or two that describes your community. This will appear in the meta tag and show up in search engines.
{app.trans('core.admin.basics_forum_description_text')}
</div>,
<textarea className="FormControl" value={this.values.forum_description()} oninput={m.withAttr('value', this.values.forum_description)}/>
]
@ -54,7 +54,7 @@ export default class BasicsPage extends Component {
{Object.keys(this.localeOptions).length > 1
? FieldSet.component({
label: 'Default Language',
label: app.trans('core.admin.basics_default_language_heading'),
children: [
Select.component({
options: this.localeOptions,
@ -65,11 +65,11 @@ export default class BasicsPage extends Component {
: ''}
{FieldSet.component({
label: 'Home Page',
label: app.trans('core.admin.basics_home_page_heading'),
className: 'BasicsPage-homePage',
children: [
<div className="helpText">
Choose the page which users will first see when they visit your forum. If entering a custom value, use the path relative to the forum root.
{app.trans('core.admin.basics_home_page_text')}
</div>,
this.homePageItems().toArray().map(({path, label}) =>
<label className="checkbox">
@ -81,11 +81,11 @@ export default class BasicsPage extends Component {
})}
{FieldSet.component({
label: 'Welcome Banner',
label: app.trans('core.admin.basics_welcome_banner_heading'),
className: 'BasicsPage-welcomeBanner',
children: [
<div className="helpText">
Configure the text that displays in the banner on the All Discussions page. Use this to welcome guests to your forum.
{app.trans('core.admin.basics_welcome_banner_text')}
</div>,
<div className="BasicsPage-welcomeBanner-input">
<input className="FormControl" value={this.values.welcome_title()} oninput={m.withAttr('value', this.values.welcome_title)}/>
@ -97,7 +97,7 @@ export default class BasicsPage extends Component {
{Button.component({
type: 'submit',
className: 'Button Button--primary',
children: 'Save Changes',
children: app.trans('core.admin.basics_submit_button'),
loading: this.loading,
disabled: !this.changed()
})}
@ -123,7 +123,7 @@ export default class BasicsPage extends Component {
items.add('allDiscussions', {
path: '/all',
label: 'All Discussions'
label: app.trans('core.admin.basics_all_discussions_label')
});
return items;
@ -143,7 +143,7 @@ export default class BasicsPage extends Component {
saveSettings(settings)
.then(() => {
app.alerts.show(this.successAlert = new Alert({type: 'success', children: 'Your changes were saved.'}));
app.alerts.show(this.successAlert = new Alert({type: 'success', children: app.trans('core.admin.basics_saved_message')}));
})
.finally(() => {
this.loading = false;

View File

@ -6,14 +6,14 @@ export default class DashboardPage extends Component {
<div className="DashboardPage">
<div className="container">
<h2>Welcome to Flarum Beta</h2>
<p>Thanks for trying out Flarum! You are running version <strong>{app.forum.attribute('version')}</strong>.</p>
<p>This <strong>beta software</strong> is provided primarily so that you can help us test it and make it better; it should not be used in production.</p>
<p>{app.trans('core.admin.dashboard_version_text', {version: <strong>{app.forum.attribute('version')}</strong>})}</p>
<p>{app.trans('core.admin.dashboard_beta_warning_text', {strong: <strong/>})}</p>
<ul>
<li>Want to look for bugs and contribute? Read the <a href="http://flarum.org/docs/contributing" target="_blank">Contributing docs</a>.</li>
<li>Having problems? Follow the instructions in the <a href="http://flarum.org/docs/troubleshooting" target="_blank">Troubleshooting docs</a>.</li>
<li>Found a bug? Please report it in our forum, under the <a href="http://discuss.flarum.org/t/support" target="_blank">Support tag</a>.</li>
<li>Got an idea to improve a feature? Tell us about it under the <a href="http://discuss.flarum.org/t/features" target="_blank">Features tag</a>.</li>
<li>Interested in developing extensions? Read the <a href="http://flarum.org/docs/extend" target="_blank">Extension docs</a>.</li>
<li>{app.trans('core.admin.dashboard_contributing_text', {a: <a href="http://flarum.org/docs/contributing" target="_blank"/>})}</li>
<li>{app.trans('core.admin.dashboard_troubleshooting_text', {a: <a href="http://flarum.org/docs/troubleshooting" target="_blank"/>})}</li>
<li>{app.trans('core.admin.dashboard_support_text', {a: <a href="http://discuss.flarum.org/t/support" target="_blank"/>})}</li>
<li>{app.trans('core.admin.dashboard_features_text', {a: <a href="http://discuss.flarum.org/t/features" target="_blank"/>})}</li>
<li>{app.trans('core.admin.dashboard_extension_text', {a: <a href="http://flarum.org/docs/extend" target="_blank"/>})}</li>
</ul>
</div>
</div>

View File

@ -28,7 +28,7 @@ export default class EditGroupModal extends Modal {
style: {backgroundColor: this.color()}
}) : '',
' ',
this.namePlural() || 'Create Group'
this.namePlural() || app.trans('core.admin.edit_group_title')
];
}
@ -37,7 +37,7 @@ export default class EditGroupModal extends Modal {
<div className="Modal-body">
<div className="Form">
<div className="Form-group">
<label>Name</label>
<label>{app.trans('core.admin.edit_group_name_label')}</label>
<div className="EditGroupModal-name-input">
<input className="FormControl" placeholder="Singular (e.g. Mod)" value={this.nameSingular()} oninput={m.withAttr('value', this.nameSingular)}/>
<input className="FormControl" placeholder="Plural (e.g. Mods)" value={this.namePlural()} oninput={m.withAttr('value', this.namePlural)}/>
@ -45,14 +45,14 @@ export default class EditGroupModal extends Modal {
</div>
<div className="Form-group">
<label>Color</label>
<label>{app.trans('core.admin.edit_group_color_label')}</label>
<input className="FormControl" placeholder="#aaaaaa" value={this.color()} oninput={m.withAttr('value', this.color)}/>
</div>
<div className="Form-group">
<label>Icon</label>
<label>{app.trans('core.admin.edit_group_icon_label')}</label>
<div className="helpText">
Enter the name of any <a href="http://fortawesome.github.io/Font-Awesome/icons/" tabindex="-1">FontAwesome</a> icon class, <em>without</em> the <code>fa-</code> prefix.
{app.trans('core.admin.edit_group_icon_text', {a: <a href="http://fortawesome.github.io/Font-Awesome/icons/" tabindex="-1"/>}, {em: <em/>}, {code: <code/>})}
</div>
<input className="FormControl" placeholder="bolt" value={this.icon()} oninput={m.withAttr('value', this.icon)}/>
</div>
@ -62,11 +62,11 @@ export default class EditGroupModal extends Modal {
type: 'submit',
className: 'Button Button--primary EditGroupModal-save',
loading: this.loading,
children: 'Save Changes'
children: app.trans('core.admin.edit_group_submit_button')
})}
{this.group.exists && this.group.id() !== Group.ADMINISTRATOR_ID ? (
<button type="button" className="Button EditGroupModal-delete" onclick={this.delete.bind(this)}>
Delete Group
{app.trans('core.admin.edit_group_delete_button')}
</button>
) : ''}
</div>
@ -95,7 +95,7 @@ export default class EditGroupModal extends Modal {
}
delete() {
if (confirm('Are you sure you want to delete this group? The group members will NOT be deleted.')) {
if (confirm(app.trans('core.admin.edit_group_delete_confirmation'))) {
this.group.delete().then(() => m.redraw());
this.hide();
}

View File

@ -18,7 +18,7 @@ export default class ExtensionsPage extends Component {
<div className="ExtensionsPage-header">
<div className="container">
{Button.component({
children: 'Add Extension',
children: app.trans('core.admin.extensions_add_button'),
icon: 'plus',
className: 'Button Button--primary',
onclick: () => app.modal.show(new AddExtensionModal())
@ -70,7 +70,7 @@ export default class ExtensionsPage extends Component {
if (app.extensionSettings[name]) {
items.add('settings', Button.component({
icon: 'cog',
children: 'Settings',
children: app.trans('core.admin.extensions_settings_button'),
onclick: app.extensionSettings[name]
}));
}
@ -78,7 +78,7 @@ export default class ExtensionsPage extends Component {
if (!enabled) {
items.add('uninstall', Button.component({
icon: 'trash-o',
children: 'Uninstall',
children: app.trans('core.admin.extensions_uninstall_button'),
onclick: () => {
app.request({
url: app.forum.attribute('apiUrl') + '/extensions/' + name,

View File

@ -10,7 +10,7 @@ export default class LoadingModal extends Modal {
}
title() {
return 'Please Wait...';
return app.trans('core.admin.extensions_loading_title');
}
content() {

View File

@ -27,9 +27,9 @@ export default class PermissionDropdown extends Dropdown {
const adminGroup = app.store.getById('groups', Group.ADMINISTRATOR_ID);
if (everyone) {
this.props.label = 'Everyone';
this.props.label = app.trans('core.admin.permissions_dropdown_everyone_button');
} else if (members) {
this.props.label = 'Members';
this.props.label = app.trans('core.admin.permissions_dropdown_members_button');
} else {
this.props.label = [
badgeForId(Group.ADMINISTRATOR_ID),
@ -40,7 +40,7 @@ export default class PermissionDropdown extends Dropdown {
if (this.props.allowGuest) {
this.props.children.push(
Button.component({
children: 'Everyone',
children: app.trans('core.admin.permissions_dropdown_everyone_button'),
icon: everyone ? 'check' : true,
onclick: () => this.save([Group.GUEST_ID])
})
@ -49,7 +49,7 @@ export default class PermissionDropdown extends Dropdown {
this.props.children.push(
Button.component({
children: 'Members',
children: app.trans('core.admin.permissions_dropdown_members_button'),
icon: members ? 'check' : true,
onclick: () => this.save([Group.MEMBER_ID])
}),

View File

@ -59,22 +59,22 @@ export default class PermissionGrid extends Component {
const items = new ItemList();
items.add('view', {
label: 'Read',
label: app.trans('core.admin.permissions_read_heading'),
children: this.viewItems().toArray()
}, 100);
items.add('start', {
label: 'Create',
label: app.trans('core.admin.permissions_create_heading'),
children: this.startItems().toArray()
}, 90);
items.add('reply', {
label: 'Participate',
label: app.trans('core.admin.permissions_participate_heading'),
children: this.replyItems().toArray()
}, 80);
items.add('moderate', {
label: 'Moderate',
label: app.trans('core.admin.permissions_moderate_heading'),
children: this.moderateItems().toArray()
}, 70);
@ -86,19 +86,19 @@ export default class PermissionGrid extends Component {
items.add('view', {
icon: 'eye',
label: 'View discussions',
label: app.trans('core.admin.permissions_view_discussions_label'),
permission: 'forum.view',
allowGuest: true
}, 100);
items.add('signUp', {
icon: 'user-plus',
label: 'Sign up',
label: app.trans('core.admin.permissions_sign_up_label'),
setting: () => SettingDropdown.component({
key: 'allow_sign_up',
options: [
{value: '1', label: 'Open'},
{value: '0', label: 'Closed'}
{value: '1', label: app.trans('core.admin.permissions_signup_open_button')},
{value: '0', label: app.trans('core.admin.permissions_signup_closed_button')}
]
})
}, 90);
@ -111,23 +111,25 @@ export default class PermissionGrid extends Component {
items.add('start', {
icon: 'edit',
label: 'Start discussions',
label: app.trans('core.admin.permissions_start_discussions_label'),
permission: 'forum.startDiscussion'
}, 100);
items.add('allowRenaming', {
icon: 'i-cursor',
label: 'Allow renaming',
label: app.trans('core.admin.permissions_allow_renaming_label'),
setting: () => {
const minutes = parseInt(app.settings.allow_renaming, 10);
return SettingDropdown.component({
defaultLabel: minutes ? `For ${minutes} minutes` : 'Indefinitely',
defaultLabel: minutes
? app.trans('core.admin.permissions_allow_some_minutes_button', {count: minutes})
: app.trans('core.admin.permissions_allow_indefinitely_button'),
key: 'allow_renaming',
options: [
{value: '-1', label: 'Indefinitely'},
{value: '10', label: 'For 10 minutes'},
{value: 'reply', label: 'Until next reply'}
{value: '-1', label: app.trans('core.admin.permissions_allow_indefinitely_button')},
{value: '10', label: app.trans('core.admin.permissions_allow_ten_minutes_button')},
{value: 'reply', label: app.trans('core.admin.permissions_allow_until_reply_button')}
]
});
}
@ -141,23 +143,25 @@ export default class PermissionGrid extends Component {
items.add('reply', {
icon: 'reply',
label: 'Reply to discussions',
label: app.trans('core.admin.permissions_reply_to_discussions_label'),
permission: 'discussion.reply'
}, 100);
items.add('allowPostEditing', {
icon: 'pencil',
label: 'Allow post editing',
label: app.trans('core.admin.permissions_allow_post_editing_label'),
setting: () => {
const minutes = parseInt(app.settings.allow_post_editing, 10);
return SettingDropdown.component({
defaultLabel: minutes ? `For ${minutes} minutes` : 'Indefinitely',
defaultLabel: minutes
? app.trans('core.admin.permissions_allow_some_minutes_button', {count: minutes})
: app.trans('core.admin.permissions_allow_indefinitely_button'),
key: 'allow_post_editing',
options: [
{value: '-1', label: 'Indefinitely'},
{value: '10', label: 'For 10 minutes'},
{value: 'reply', label: 'Until next reply'}
{value: '-1', label: app.trans('core.admin.permissions_allow_indefinitely_button')},
{value: '10', label: app.trans('core.admin.permissions_allow_ten_minutes_button')},
{value: 'reply', label: app.trans('core.admin.permissions_allow_until_reply_button')}
]
});
}
@ -171,31 +175,31 @@ export default class PermissionGrid extends Component {
items.add('renameDiscussions', {
icon: 'i-cursor',
label: 'Rename discussions',
label: app.trans('core.admin.permissions_rename_discussions_label'),
permission: 'discussion.rename'
}, 100);
items.add('hideDiscussions', {
icon: 'trash-o',
label: 'Delete discussions',
label: app.trans('core.admin.permissions_delete_discussions_label'),
permission: 'discussion.hide'
}, 90);
items.add('deleteDiscussions', {
icon: 'times',
label: 'Delete discussions forever',
label: app.trans('core.admin.permissions_delete_discussions_forever_label'),
permission: 'discussion.delete'
}, 80);
items.add('editPosts', {
icon: 'pencil',
label: 'Edit and delete posts',
label: app.trans('core.admin.permissions_edit_and_delete_posts_label'),
permission: 'discussion.editPosts'
}, 70);
items.add('deletePosts', {
icon: 'times',
label: 'Delete posts forever',
label: app.trans('core.admin.permissions_delete_posts_forever_label'),
permission: 'discussion.deletePosts'
}, 60);
@ -206,7 +210,7 @@ export default class PermissionGrid extends Component {
const items = new ItemList();
items.add('global', {
label: 'Global',
label: app.trans('core.admin.permissions_global_heading'),
render: item => {
if (item.setting) {
return item.setting();

View File

@ -25,7 +25,7 @@ export default class PermissionsPage extends Component {
))}
<button className="Button Group Group--add" onclick={() => app.modal.show(new EditGroupModal())}>
{icon('plus', {className: 'Group-icon'})}
<span className="Group-name">New Group</span>
<span className="Group-name">{app.trans('core.admin.permissions_new_group_button')}</span>
</button>
</div>
</div>

View File

@ -43,7 +43,7 @@ export default class SessionDropdown extends Dropdown {
items.add('logOut',
Button.component({
icon: 'sign-out',
children: app.trans('core.log_out'),
children: app.trans('core.admin.header_log_out_button'),
onclick: app.session.logout.bind(app.session)
}),
-100