feat: Add multi-language support (i18n)

Languages supported (8):
- English (en)
- 日本語 (ja)
- Deutsch (de)
- Français (fr)
- Español (es)
- 简体中文 (zh-CN)
- 繁體中文 (zh-TW)
- 한국어 (ko)

Changes:
- Add locale column to users table
- Add SetLocale middleware for automatic locale detection
- Add LocaleController for language switching
- Create language files with translations for all UI elements
- Add language selector to user profile page
- Update all Blade views to use translation strings
This commit is contained in:
2025-11-29 12:00:09 +09:00
parent ecfa21d56c
commit cdf0bf4bad
25 changed files with 1183 additions and 84 deletions

View File

@@ -15,7 +15,7 @@
<!-- Header -->
<div class="mb-6 flex items-center justify-between">
<h1 class="text-3xl font-bold text-gray-900">
{{ $isEditMode ? 'Edit Document' : 'New Document' }}
{{ $isEditMode ? __('messages.documents.edit_document') : __('messages.documents.new_document') }}
</h1>
<div class="flex space-x-3">
@@ -24,22 +24,22 @@
href="{{ route('documents.show', $document) }}"
class="inline-flex items-center px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50"
>
Cancel
{{ __('messages.common.cancel') }}
</a>
<button
wire:click="delete"
wire:confirm="Are you sure you want to delete this document?"
wire:confirm="{{ __('messages.documents.delete_confirm') }}"
class="inline-flex items-center px-4 py-2 border border-red-300 rounded-md text-sm font-medium text-red-700 bg-white hover:bg-red-50"
>
Delete
{{ __('messages.documents.delete') }}
</button>
@else
<a
href="{{ route('documents.show', 'home') }}"
class="inline-flex items-center px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50"
>
Cancel
{{ __('messages.common.cancel') }}
</a>
@endif
@@ -50,7 +50,7 @@ class="inline-flex items-center px-4 py-2 bg-indigo-600 border border-transparen
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4"></path>
</svg>
Save
{{ __('messages.documents.save') }}
</button>
</div>
</div>
@@ -60,27 +60,27 @@ class="inline-flex items-center px-4 py-2 bg-indigo-600 border border-transparen
<!-- Title -->
<div>
<label for="title" class="block text-sm font-medium text-gray-700 mb-2">
Title
{{ __('messages.documents.title_label') }}
</label>
<input
type="text"
id="title"
wire:model="title"
class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
placeholder="Document Title (use / for folders, e.g. Laravel/Livewire/Components)"
placeholder="{{ __('messages.documents.title_placeholder') }}"
>
@error('title')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-1 text-xs text-gray-500">
Tip: Use slashes (/) in the title to organize documents into folders automatically
{{ __('messages.documents.title_hint') }}
</p>
</div>
<!-- Markdown Editor -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">
Content
{{ __('messages.documents.content_label') }}
</label>
<div wire:ignore>
<div x-data="markdownEditor()" x-init="initEditor()">
@@ -103,12 +103,12 @@ class="w-full"
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
Saving...
{{ __('messages.documents.saving') }}
</div>
@if($isEditMode && $document)
<div>
Path: <code class="text-xs bg-gray-100 px-2 py-1 rounded">{{ $document->path }}</code>
{{ __('messages.documents.path') }}: <code class="text-xs bg-gray-100 px-2 py-1 rounded">{{ $document->path }}</code>
</div>
@endif
</div>
@@ -137,7 +137,7 @@ class="w-full"
autosave: {
enabled: false,
},
placeholder: 'Write your markdown here...',
placeholder: '{{ __("messages.documents.content_placeholder") }}',
toolbar: [
'bold', 'italic', 'heading', '|',
'quote', 'unordered-list', 'ordered-list', '|',
@@ -148,9 +148,7 @@ class="w-full"
status: ['lines', 'words', 'cursor'],
});
// エディタの変更をLivewireに反映
this.editor.codemirror.on('change', () => {
// wire:ignoreの外にあるhidden inputを探す
const formElement = this.$el.closest('form');
const hiddenInput = formElement.querySelector('input[type="hidden"][wire\\:model="content"]');
if (hiddenInput) {