Skip to content

Commit

Permalink
Finalize almost all the translation system.
Browse files Browse the repository at this point in the history
JS loading is next
  • Loading branch information
Repflez committed Sep 13, 2021
1 parent 62fe9a1 commit 6573149
Show file tree
Hide file tree
Showing 8 changed files with 362 additions and 62 deletions.
51 changes: 51 additions & 0 deletions database/2021_09_13_045434_add_post_languages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Miiverse\DB;

class AddPostLanguages extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$schema = DB::getSchemaBuilder();

$schema->table('posts', function (Blueprint $table) {
$table->smallInteger('language')->default(1);
});

// Edit user language column
$schema->table('users', function (Blueprint $table) {
$table->dropColumn('lang');

$table->smallInteger('language')->default(1);
$table->smallInteger('post_language')->default(99);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$schema = DB::getSchemaBuilder();

$schema->table('posts', function (Blueprint $table) {
$table->dropColumn('language');
});

$schema->table('users', function (Blueprint $table) {
$table->dropColumn('language');
$table->dropColumn('post_language');

$table->string('lang', 2)->default('en');
});
}
}
45 changes: 45 additions & 0 deletions resources/lang/en/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/*
* Translation file for settings
*/

return [
// Account settings
'account' => [
'title' => ':name Settings',

'display_language' => [
'title' => 'In what language you want :name to be displayed in?',
'note' => 'Note: This setting does not affect what language posts are displayed in.',
],

'post_language' => [
'title' => 'In what language do you want to see posts in :name?',
'note' => 'Note: This setting does not affect what language :name is displayed in.',

'all_languages' => 'All Languages',
],

'submit' => 'Save Settings',
],

// Profile Settings
'profile' => [
'title' => 'Profile Settings',

// Profile Comment
'comment' => [
'section_name' => 'Profile Comment',
'placeholder' => 'Write about yourself here.',
'note' => 'Attention',
'note_content' => 'Please refrain from including any of the following information:<br>
- Your address, telephone number, e-mail address, the name of your school, or any other information that could personally identify you. <br>
- Links to external websites which could be used to contact you directly.<br>
- Any other content prohibited by the :name Code of Conduct.<br>
Posting such information is against the :name Code of Conduct and may result in your profile being hidden from the public.',
],

// Submit button
'submit' => 'Save Settings',
],
];
57 changes: 57 additions & 0 deletions resources/views/3ds/settings/account.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{% set class = 'setting-account' %}
{% extends '@3ds/_master.twig' %}

{% block content %}
{% set name = config('general.name') %}
<div id="header" class="icon-header">
<div id="header-body">
<h1 id="page-title">
<span>{{ __('settings.account.title', { name: name }) }}</span>
</h1>
</div>
</div>

<div class="body-content">
<div class="settings-list-content">
<form id="account-settings-form" class="setting-form" method="post" action="{{ route('settings.accountsave') }}">
<ul class="settings-list">
<li class="scroll">
<p class="settings-label">
<label for="select_language">{{ __('settings.account.display_language.title', { name: name }) }}</label>
</p>
<p class="note">{{ __('settings.account.display_language.note', { name: name }) }}</p>
<div class="select-content">
<div class="select-button">
<span class="select-button-content">{{ selected_display_language }}</span>
<select class="scroll-focus" name="language" id="select_language">
{% for language in display_languages %}
<option value="{{ language.code }}"{% if language.selected %} selected=""{% endif %}>{{ language.title }}</option>
{% endfor %}
</select>
</div>
</div>
</li>
<li class="scroll">
<p class="settings-label">
<label for="select_visible_language">{{ __('settings.account.post_language.title', { name: name }) }}</label>
</p>
<p class="note">{{ __('settings.account.post_language.note', { name: name }) }}</p>
<div class="select-content">
<div class="select-button">
<span class="select-button-content">{{ selected_post_language }}</span>
<select class="scroll-focus" name="visible_language" id="select_visible_language">
{% for language in post_languages %}
<option value="{{ language.code }}"{% if language.selected %} selected=""{% endif %}>{{ language.title }}</option>
{% endfor %}
</select>
</div>
</div>
</li>
<div class="form-buttons scroll">
<input type="submit" class="black-button apply-button scroll-focus" value="{{ __('settings.account.submit') }}">
</div>
</form>
</div>
</div>
</div>
{% endblock %}
29 changes: 29 additions & 0 deletions resources/views/3ds/settings/profile.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% set class = 'setting-profile' %}
{% extends '@3ds/_master.twig' %}

{% block content %}
{% set name = config('general.name') %}
<div id="header" class="icon-header">
<div id="header-body">
<h1 id="page-title"><span>{{ __('settings.profile.title') }}</span></h1>
</div>
</div>
<div class="body-content">
<div class="settings-list-content">
<form id="profile-settings-form" class="setting-form" method="post" action="{{ route('settings.profile') }}">
<ul class="display-name"></ul>
<ul class="settings-list">
<li class="setting-profile-comment scroll">
<p class="settings-label">{{ __('settings.profile.comment.section_name') }}</p>
<textarea id="profile-text" class="textarea scroll-focus" name="profile_comment" maxlength="400" placeholder="{{ __('settings.profile.comment.placeholder') }}"></textarea>
<p class="note-attention">{{ __('settings.profile.comment.note') }}</p>
<p class="note">{{ __('settings.profile.comment.note_content', { name: config('general.name') })|raw }}</p>
</li>
</ul>
<div class="form-buttons scroll">
<input type="submit" class="black-button apply-button scroll-focus" value="{{ __('settings.profile.submit') }}">
</div>
</form>
</div>
</div>
{% endblock %}
4 changes: 2 additions & 2 deletions routes/3ds.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@
Router::post('/played_title_ids', 'CTR.Dummy@dummy', 'settings.playedtitles');

// Account settings
Router::get('/aacount', 'CTR.Settings@account', 'settings.account');
Router::post('/aacount', 'CTR.Settings@account_save', 'settings.accountsave');
Router::get('/account', 'CTR.Settings@account', 'settings.account');
Router::post('/account', 'CTR.Settings@account_save', 'settings.accountsave');
});

// Welcome
Expand Down
100 changes: 99 additions & 1 deletion src/Pages/CTR/Settings.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

/**
* Holds the settings page.
*/

namespace Miiverse\Pages\CTR;

use Miiverse\CurrentSession;
use Miiverse\Translation;
use Miiverse\DB;

/**
Expand All @@ -20,7 +22,7 @@ class Settings extends Page
*
* @return string
*/
public function tutorial_post() : string
public function tutorial_post(): string
{
$tutorial_name = $_POST['tutorial_name'];
$database_key = '';
Expand All @@ -46,4 +48,100 @@ public function tutorial_post() : string

return '{"success":1}';
}


/**
* Page for users to set their account details.
*
* @return string
*/
public function account(): string
{
$user = CurrentSession::$user;

$display_languages = [
0 => [
'title' => '日本語',
'code' => Translation::LANGUAGE_JAPANESE,
'selected' => $user->language === 0,
],
1 => [
'title' => 'English',
'code' => Translation::LANGUAGE_ENGLISH,
'selected' => $user->language === 1,
],
2 => [
'title' => 'Français',
'code' => Translation::LANGUAGE_FRENCH,
'selected' => $user->language === 2,
],
3 => [
'title' => 'Deutsch',
'code' => Translation::LANGUAGE_GERMAN,
'selected' => $user->language === 3,
],
4 => [
'title' => 'Italiano',
'code' => Translation::LANGUAGE_ITALIAN,
'selected' => $user->language === 4,
],
5 => [
'title' => 'Español',
'code' => Translation::LANGUAGE_SPANISH,
'selected' => $user->language === 5,
],
6 => [
'title' => '汉语',
'code' => Translation::LANGUAGE_SIMPLIFIED_CHINESE,
'selected' => $user->language === 6,
],
7 => [
'title' => '한국어',
'code' => Translation::LANGUAGE_KOREAN,
'selected' => $user->language === 7,
],
8 => [
'title' => 'Nederlands',
'code' => Translation::LANGUAGE_DUTCH,
'selected' => $user->language === 8,
],
9 => [
'title' => 'Português',
'code' => Translation::LANGUAGE_PORTUGUESE,
'selected' => $user->language === 9,
],
10 => [
'title' => 'Русский',
'code' => Translation::LANGUAGE_RUSSIAN,
'selected' => $user->language === 10,
],
11 => [
'title' => '漢語',
'code' => Translation::LANGUAGE_TRADITIONAL_CHINESE,
'selected' => $user->language === 11,
],
];
$selected_display_language = $display_languages[$user->language]['title'];
$post_languages = [
99 => [
'title' => __('settings.account.post_language.all_languages'),
'code' => Translation::LANGUAGE_SYSTEM,
'selected' => $user->post_language === 99,
],
];
$post_languages += $display_languages;
$selected_post_language = $post_languages[$user->post_language]['title'];

return view('settings/account', compact(
'display_languages',
'selected_display_language',
'post_languages',
'selected_post_language'
));
}

public function profileView(): string
{
return view('settings/profile');
}
}
Loading

0 comments on commit 6573149

Please sign in to comment.