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>,
) -> LangFilePath
pub fn new( pkg_name: impl Into<Txt>, pkg_version: Version, file: impl Into<Txt>, ) -> LangFilePath
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: &LangFilePath) -> Option<u64>
pub fn matches(&self, search: &LangFilePath) -> 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<LangFilePath, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LangFilePath, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl From<&'static str> for LangFilePath
impl From<&'static str> for LangFilePath
source§fn from(file: &'static str) -> LangFilePath
fn from(file: &'static str) -> LangFilePath
source§impl From<String> for LangFilePath
impl From<String> for LangFilePath
source§fn from(file: String) -> LangFilePath
fn from(file: String) -> LangFilePath
source§impl From<Txt> for LangFilePath
impl From<Txt> for LangFilePath
source§fn from(file: Txt) -> LangFilePath
fn from(file: Txt) -> LangFilePath
source§impl Hash for LangFilePath
impl Hash for LangFilePath
source§impl IntoVar<LangFilePath> for &'static str
impl IntoVar<LangFilePath> for &'static str
source§fn into_var(self) -> <&'static str as IntoVar<LangFilePath>>::Var
fn into_var(self) -> <&'static str as IntoVar<LangFilePath>>::Var
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl IntoVar<LangFilePath> for String
impl IntoVar<LangFilePath> for String
source§fn into_var(self) -> <String as IntoVar<LangFilePath>>::Var
fn into_var(self) -> <String as IntoVar<LangFilePath>>::Var
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl IntoVar<LangFilePath> for Txt
impl IntoVar<LangFilePath> for Txt
source§fn into_var(self) -> <Txt as IntoVar<LangFilePath>>::Var
fn into_var(self) -> <Txt as IntoVar<LangFilePath>>::Var
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
BoxedVar<T>
. Read moresource§impl Ord for LangFilePath
impl Ord for LangFilePath
source§fn cmp(&self, other: &LangFilePath) -> Ordering
fn cmp(&self, other: &LangFilePath) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
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
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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