Merge branch 'a1phyr/fix_list_localization' into 'master'

Fix i18n::list_localizations

Closes #910

See merge request veloren/veloren!1673
This commit is contained in:
Imbris 2021-01-03 19:36:35 +00:00
commit da8fdafd6a
2 changed files with 7 additions and 1 deletions

View File

@ -205,6 +205,11 @@ lazy_static! {
};
}
/// Returns the actual path of the specifier with the extension.
///
/// For directories, give `""` as extension.
pub fn path_of(specifier: &str, ext: &str) -> PathBuf { ASSETS.source().path_of(specifier, ext) }
fn get_dir_files(files: &mut Vec<String>, path: &Path, specifier: &str) -> io::Result<()> {
for entry in fs::read_dir(path)? {
if let Ok(entry) = entry {

View File

@ -251,7 +251,8 @@ impl assets::Compound for Localization {
pub fn list_localizations() -> Vec<LanguageMetadata> {
let mut languages = vec![];
// List language directories
for i18n_directory in std::fs::read_dir("assets/voxygen/i18n").unwrap() {
let i18n_root = assets::path_of("voxygen.i18n", "");
for i18n_directory in std::fs::read_dir(&i18n_root).unwrap() {
if let Ok(i18n_entry) = i18n_directory {
if let Some(i18n_key) = i18n_entry.file_name().to_str() {
// load the root file of all the subdirectories