Struct Pseudolocalizer

Source
pub struct Pseudolocalizer<'a> { /* private fields */ }
Expand description

A configurable struct which can pseudolocalize strings.

Implementations§

Source§

impl<'a> Pseudolocalizer<'a>

Source

pub fn new() -> Self

Create a default Pseudolocalizer.

Source

pub fn transform(&self, string: &str) -> String

Transform a string into a pseudolocalized string according to the Pseudolocalizer’s configuration.

Source

pub fn with_extension_string(self, extension: &'a str) -> Self

Set the extension string, i.e. the string used to increase the length of pseudolocalized strings (if the extension value is positive).

Source

pub fn with_increase_percentage(self, increase: u32) -> Self

Set the increase rate of a string in percent.

Pseudolocalized strings shall contain the extension string (which may be cropped or repeated) so that the overall string gets larger.

For example an increase of 27% means that pseudolocalized strings shall be 1.27 times longer than the original string (not accounting for the prefix and suffix).

Please note that a naïve method is used to compute the length (based on the number of chars) and thus, the increase rate may not be exact.

Source

pub fn with_prefix(self, prefix: &'a str) -> Self

Set the prefix, i.e. the string with which pseudolocalized strings shall start.

Source

pub fn with_suffix(self, suffix: &'a str) -> Self

Set the suffix, i.e. the string with which pseudolocalized strings shall end.

Source

pub fn with_transform_function( self, transform_function: fn(&str) -> String, ) -> Self

Set the transform function which can transform an input string into a string with similar-looking characters.

Source

pub fn prefix(&self) -> &str

Get the string slice with which pseudolocalized strings shall start.

Source

pub fn suffix(&self) -> &str

Get the string slice with which pseudolocalized strings shall end.

Source

pub fn transform_function(&self) -> &fn(s: &str) -> String

Get the function used for pseudolocalizing strings.

Auto Trait Implementations§

§

impl<'a> Freeze for Pseudolocalizer<'a>

§

impl<'a> RefUnwindSafe for Pseudolocalizer<'a>

§

impl<'a> Send for Pseudolocalizer<'a>

§

impl<'a> Sync for Pseudolocalizer<'a>

§

impl<'a> Unpin for Pseudolocalizer<'a>

§

impl<'a> UnwindSafe for Pseudolocalizer<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.