Struct zng_ext_l10n::LangFilePath
source · pub struct LangFilePath {
pub pkg_name: Txt,
pub pkg_version: Version,
pub file: Txt,
}
Expand description
Localization resource file path in the localization directory.
In the default directory layout, localization dependencies are collected using cargo zng l10n
and copied to l10n/{lang}/deps/{name}/{version}/
, and localization for the app (is_current_app
)
is placed in l10n/{lang}/
.
Fields§
§pkg_name: Txt
Package name.
pkg_version: Version
Package version.
file: Txt
The file name.
Implementations§
source§impl LangFilePath
impl LangFilePath
sourcepub fn new(
pkg_name: impl Into<Txt>,
pkg_version: Version,
file: impl Into<Txt>,
) -> Self
pub fn new( pkg_name: impl Into<Txt>, pkg_version: Version, file: impl Into<Txt>, ) -> Self
New from package name, version and file.
sourcepub fn current_app(file: impl Into<Txt>) -> LangFilePath
pub fn current_app(file: impl Into<Txt>) -> LangFilePath
Gets a file in the current app.
This value indicates that the localization resources are directly on the l10n/{lang?}/
directories, not
in the dependencies directories.
See zng_env::about()
for more details.
sourcepub fn is_current_app(&self) -> bool
pub fn is_current_app(&self) -> bool
Gets if this file is in the current_app
resources, or the pkg_name
is empty or the pkg_version.pre
is #.#.#-local
.
sourcepub fn pkg_name(&self) -> Txt
pub fn pkg_name(&self) -> Txt
Gets the normalized package name.
This is the app package name if is_current_app
, otherwise is just the pkg_name
value.
sourcepub fn pkg_version(&self) -> Version
pub fn pkg_version(&self) -> Version
Gets the normalized package version.
This is the app version if is_current_app
, otherwise is just the pkg_version
value.
sourcepub fn to_path(&self, lang: &Lang) -> PathBuf
pub fn to_path(&self, lang: &Lang) -> PathBuf
Get the file path, relative to the localization dir.
- Empty file name is the same as
_
. - If package
is_current_app
gets{lang}/{file}.ftl
. - Else if is another package gets
{lang}/deps/{pkg_name}/{pkg_version}/{file}.ftl
.
sourcepub fn matches(&self, search: &Self) -> Option<u64>
pub fn matches(&self, search: &Self) -> Option<u64>
Gets a value that indicates if the resources represented by self
can be used for search
.
The number indicates the quality of the match:
0
is an exact match.b1
is a match with only versionbuild
differences.b10
is a match with only versionpre
differences.(0..u16::MAX) << 16
is a match with onlypatch
differences and the absolute distance.(0..u16::MAX) << 16 * 2
is a match withminor
differences and the absolute distance.(0..u16::MAX) << 16 * 3
is a match withmajor
differences and the absolute distance.None`` is a
pkg_name` mismatch.
Trait Implementations§
source§impl Clone for LangFilePath
impl Clone for LangFilePath
source§fn clone(&self) -> LangFilePath
fn clone(&self) -> LangFilePath
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for LangFilePath
impl Debug for LangFilePath
source§impl<'de> Deserialize<'de> for LangFilePath
impl<'de> Deserialize<'de> for LangFilePath
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<&'static str> for LangFilePath
impl From<&'static str> for LangFilePath
source§impl From<String> for LangFilePath
impl From<String> for LangFilePath
source§impl From<Txt> for LangFilePath
impl From<Txt> for LangFilePath
source§impl Hash for LangFilePath
impl Hash for LangFilePath
source§impl IntoVar<LangFilePath> for &'static str
impl IntoVar<LangFilePath> for &'static str
source§impl IntoVar<LangFilePath> for String
impl IntoVar<LangFilePath> for String
source§impl IntoVar<LangFilePath> for Txt
impl IntoVar<LangFilePath> for Txt
source§impl Ord for LangFilePath
impl Ord for LangFilePath
source§impl PartialEq for LangFilePath
impl PartialEq for LangFilePath
source§impl PartialOrd for LangFilePath
impl PartialOrd for LangFilePath
source§impl Serialize for LangFilePath
impl Serialize for LangFilePath
impl Eq for LangFilePath
impl IntoValue<LangFilePath> for &'static str
impl IntoValue<LangFilePath> for String
impl IntoValue<LangFilePath> for Txt
Auto Trait Implementations§
impl Freeze for LangFilePath
impl RefUnwindSafe for LangFilePath
impl Send for LangFilePath
impl Sync for LangFilePath
impl Unpin for LangFilePath
impl UnwindSafe for LangFilePath
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more