Skip to content

Commit

Permalink
Enable Old Language Features (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Jun 22, 2020
1 parent e135902 commit 3284408
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Internationalization Extension for Mecha
Release Notes
-------------



### 1.1.0

- Added ability to load custom translation items from third party layout and extensions by storing the translation items data in `.\lot\layout\language` or `.\lot\x\*\lot\language` folder.

### 1.0.1, 1.0.2, 1.0.3

- Added more translation items.
Expand Down
2 changes: 1 addition & 1 deletion language/about.page
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Internationalization
description: Set language phrases automatically based on the current `language` state value.
author: Taufik Nurrohman
type: Markdown
version: 1.0.3
version: 1.1.0
...

Translation data will be focused on the `.\lot\x\language\state\id.php` file. If you want to contribute, be sure to follow the data in that file.
23 changes: 21 additions & 2 deletions language/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
<?php

if (is_file($f = __DIR__ . DS . 'state' . DS . $state->language . '.php')) {
$id = $state->language;
$files = [];

// Queue default translation item(s) from this extension
if (is_file($file = __DIR__ . DS . 'state' . DS . $id . '.php')) {
$files[] = $file;
}

// Queue custom translation item(s) from third party extension(s)
foreach (glob(__DIR__ . DS . '..' . DS . '*' . DS . 'lot' . DS . 'language' . DS . $id . '.php', GLOB_NOSORT) as $file) {
$files[] = $file;
}

// Queue custom translation item(s) from third party layout
if (is_file($file = __DIR__ . DS . '..' . DS . '..' . DS . 'layout' . DS . 'language' . DS . $id . '.php')) {
$files[] = $file;
}

// Load and merge translation item(s) from queue
foreach ($files as $file) {
$data = (function($f) {
extract($GLOBALS, EXTR_SKIP);
return (array) require $f;
})($f);
})($file);
// Automatic lower-case mode
foreach ($data as $k => $v) {
$kk = strtolower($k);
Expand Down
1 change: 1 addition & 0 deletions language/state/id.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
'Folder %s successfully updated.' => 'Folder %s berhasil diperbarui.',
'Invalid %s format.' => 'Format %s tidak valid.',
'Invalid token.' => 'Token tidak valid.',
'Invalid user or pass.' => 'Pengguna atau kunci yang Anda berikan tidak valid.',
'Logged in.' => 'Berhasil masuk.',
'Logged out.' => 'Berhasil keluar.',
'Maximum file size allowed to upload is %s.' => 'Ukuran berkas maksimal untuk diunggah adalah %s.',
Expand Down

0 comments on commit 3284408

Please sign in to comment.