Explorer

definy.localized-texts-set

description
The texts with the text of the language replaced (added at the end if it is not there). An empty text removes the language
type
Fn(texts: List<@core.localized-text>, language: String, text: String) -> List<@core.localized-text>
expression
fn(texts$0, language$1, text$2) =>
  let replaced$3 = @core.list-fold(
      T: @core.localized-text,
      A: Record{found: Boolean, items: List<@core.localized-text>},
      reducer: fn(acc$4, item$5) =>
        match @core.equal(left: $5.language, right: $1) {
          true =>
            match @core.or(left: $4.found, right: @core.equal(left: $2, right: "")) {
              true =>
                $4,
              false =>
                {found: true, items: @core.list-append(list: $4.items, item: {language: $1, text: $2})}
            },
          false =>
            {found: $4.found, items: @core.list-append(list: $4.items, item: $5)}
        },
      init: {found: false, items: []},
      xs: $0
    );
  match @core.or(left: $3.found, right: @core.equal(left: $2, right: "")) {
    true =>
      $3.items,
    false =>
      @core.list-append(list: $3.items, item: {language: $1, text: $2})
  }
visibility
public
definy.localized-texts-set (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: 196VMCO7cGkMR_hSox388Do5TDno0IgPghhASPHVtxk
content hash: x_8ZkyS24-gnP-bjHrgH29lE6pb69MxUZAafshPctcI