mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 08:22:41 +08:00
Update for composer branch, add svg icon
This commit is contained in:
parent
d2cb4c2d77
commit
520d52a048
10
extensions/lang-english/assets/icon.svg
Normal file
10
extensions/lang-english/assets/icon.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30" width="1200" height="600">
|
||||
<clipPath id="t">
|
||||
<path d="M30,15 h30 v15 z v15 h-30 z h-30 v-15 z v-15 h30 z"/>
|
||||
</clipPath>
|
||||
<path d="M0,0 v30 h60 v-30 z" fill="#00247d"/>
|
||||
<path d="M0,0 L60,30 M60,0 L0,30" stroke="#fff" stroke-width="6"/>
|
||||
<path d="M0,0 L60,30 M60,0 L0,30" clip-path="url(#t)" stroke="#cf142b" stroke-width="4"/>
|
||||
<path d="M30,0 v30 M0,15 h60" stroke="#fff" stroke-width="10"/>
|
||||
<path d="M30,0 v30 M0,15 h60" stroke="#cf142b" stroke-width="6"/>
|
||||
</svg>
|
After Width: | Height: | Size: 522 B |
@ -1,31 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Flarum\Events\RegisterLocales;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Flarum\Core\Application;
|
||||
|
||||
return function (Dispatcher $events) {
|
||||
$events->listen(RegisterLocales::class, function(RegisterLocales $event) {
|
||||
$locale = $name = null;
|
||||
return function (Application $app) {
|
||||
$app->make('events')->listen(RegisterLocales::class, function(RegisterLocales $event) {
|
||||
$name = $title = basename(__DIR__);
|
||||
|
||||
if (file_exists($manifest = __DIR__.'/flarum.json')) {
|
||||
if (file_exists($manifest = __DIR__.'/composer.json')) {
|
||||
$json = json_decode(file_get_contents($manifest), true);
|
||||
$locale = array_key_exists('locale', $json) ? $json['locale'] : null;
|
||||
$name = array_key_exists('name', $json) ? $json['name'] : null;
|
||||
unset($json);
|
||||
|
||||
if (empty($json)) {
|
||||
throw new RuntimeException("Error parsing composer.json in $name: ".json_last_error_msg());
|
||||
}
|
||||
|
||||
$locale = array_get($json, 'extra.flarum-locale.code');
|
||||
$title = array_get($json, 'extra.flarum-locale.title', $title);
|
||||
}
|
||||
|
||||
if ($name === null) {
|
||||
throw new RuntimeException("Language pack ".__DIR__." needs a \"name\" in flarum.json.");
|
||||
if (! isset($locale)) {
|
||||
throw new RuntimeException("Language pack $name must define \"extra.flarum-locale.code\" in composer.json.");
|
||||
}
|
||||
|
||||
if ($locale === null) {
|
||||
throw new RuntimeException("Language pack {$name} needs a \"locale\" in flarum.json.");
|
||||
}
|
||||
|
||||
$event->addLocale($locale, $name);
|
||||
$event->addLocale($locale, $title);
|
||||
|
||||
if (! is_dir($localeDir = __DIR__.'/locale')) {
|
||||
throw new RuntimeException("Language pack {$name} needs a \"locale\" subdirectory.");
|
||||
throw new RuntimeException("Language pack $name must have a \"locale\" subdirectory.");
|
||||
}
|
||||
|
||||
if (file_exists($file = $localeDir.'/config.js')) {
|
||||
@ -36,9 +36,7 @@ return function (Dispatcher $events) {
|
||||
$event->addConfig($locale, $file);
|
||||
}
|
||||
|
||||
$files = new DirectoryIterator($localeDir);
|
||||
|
||||
foreach ($files as $file) {
|
||||
foreach (new DirectoryIterator($localeDir) as $file) {
|
||||
if ($file->isFile() && in_array($file->getExtension(), ['yml', 'yaml'])) {
|
||||
$event->addTranslations($locale, $file->getPathname());
|
||||
}
|
||||
|
29
extensions/lang-english/composer.json
Normal file
29
extensions/lang-english/composer.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "flarum/english",
|
||||
"type": "flarum-extension",
|
||||
"description": "English language pack.",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"composer/installers": "dev-master"
|
||||
},
|
||||
"extra": {
|
||||
"flarum-extension": {
|
||||
"title": "English",
|
||||
"icon": {
|
||||
"backgroundImage": "url('{$assets}/icon.svg')",
|
||||
"backgroundSize": "cover",
|
||||
"backgroundPosition": "center"
|
||||
}
|
||||
},
|
||||
"flarum-locale": {
|
||||
"code": "en",
|
||||
"title": "English"
|
||||
}
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/tobscure/installers"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"name": "english",
|
||||
"title": "English",
|
||||
"locale": "en",
|
||||
"description": "English language pack.",
|
||||
"keywords": ["language"],
|
||||
"version": "0.1.0-beta.3",
|
||||
"author": {
|
||||
"name": "Toby Zerner",
|
||||
"email": "toby@flarum.org",
|
||||
"homepage": "http://tobyzerner.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"flarum": ">=0.1.0-beta.3"
|
||||
},
|
||||
"support": {
|
||||
"source": "https://github.com/flarum/english",
|
||||
"issues": "https://github.com/flarum/core/issues"
|
||||
},
|
||||
"icon": {
|
||||
"name": "language",
|
||||
"backgroundColor": "#eee",
|
||||
"color": "#000"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user