-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
toby7002
committed
Oct 1, 2023
1 parent
20044e7
commit ce5225e
Showing
7 changed files
with
141 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
availableLanguages: ["en_us"] # DON'T TOUCH THIS LINE | ||
lang: en_us |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"message.cache.running": "§eTask is running! Please wait until it is finished", | ||
"message.cache.failed": "§cCould not get Poggit plugins list from Poggit: {%reason}", | ||
"message.cache.successfully": "§a({%count}) Poggit plugins has been cached successfully" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace thebigcrafter\omp\commands; | ||
|
||
class OMPCommand {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace thebigcrafter\omp\lang; | ||
|
||
use Exception; | ||
use thebigcrafter\Sulfur\Filesystem; | ||
|
||
class OMPLanguage | ||
{ | ||
/** @var array<string, string> $languages */ | ||
private static array $languages; | ||
|
||
private $default; | ||
|
||
public static function loadLanguageFile(string $name, string $path) | ||
{ | ||
if (!file_exists($path)) { | ||
throw new Exception('File not found.'); | ||
} | ||
|
||
self::$languages[$name] = json_decode(\thebigcrafter\omp\utils\Filesystem::readFile($path)->await() ?: '', true); | ||
} | ||
|
||
public function __construct(string $default) | ||
{ | ||
if (!array_key_exists($default, self::$languages)) { | ||
throw new Exception('Language not found'); | ||
} | ||
|
||
$this->default = $default; | ||
} | ||
|
||
public function setDefaultLanguage(string $name) | ||
{ | ||
if (!array_key_exists($name, self::$languages)) { | ||
throw new Exception('Language not found'); | ||
} | ||
|
||
$this->default = $name; | ||
} | ||
|
||
public function get(string $key) | ||
{ | ||
if (!array_key_exists($key, self::$languages[$this->default])) { | ||
throw new Exception("$key not found"); | ||
} | ||
|
||
return self::$languages[$this->default][$key]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace thebigcrafter\omp\utils; | ||
|
||
use Exception; | ||
use thebigcrafter\Fluorine\Fluorine; | ||
use thebigcrafter\Iodine\DeferredFuture; | ||
use thebigcrafter\Iodine\Iodine; | ||
use thebigcrafter\Sulfur\Path; | ||
|
||
class Filesystem | ||
{ | ||
public static function readFile(string $path) | ||
{ | ||
if (!file_exists($path)) { | ||
throw new Exception("File not found"); | ||
} | ||
|
||
return Iodine::async(function () use ($path) { | ||
return file_get_contents($path); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters