Accent Removal

  • amieldylan-1340904698760400958

    Amiel Dylan

    26 days ago

    Hello toddle community.
    I would like to design a function that does the following: removeAccents = (str) => {
    return str
    .replace(/[àáâãäå]/g, 'a')
    .replace(/[èéêë]/g, 'e')
    .replace(/[ìíîï]/g, 'i')
    .replace(/[òóôõö]/g, 'o')
    .replace(/[ùúûü]/g, 'u')
    .replace(/[ýÿ]/g, 'y')
    .replace(/[ñ]/g, 'n')
    .replace(/[ç]/g, 'c');
    };
    But this is impossible without the use of several nested “ReplaceAll. Do you have any suggestions? Thank you!
    1
    1
  • andreasmoller-1340921389145915423

    Andreas Møller

    26 days ago

    If it is not used during Server render then you could just create a custom formula
  • amieldylan-1340924416283906179

    Amiel Dylan

    26 days ago

    I tried with several Replace All nested or a map reduce but I hadn't thought of custom formulas. I'll try
  • amieldylan-1340932111019802704

    Amiel Dylan

    26 days ago

    @Andreas Møller Sorry to bother you but, I created a custom function that completely replaced one of my components. Even when I click on the component, the name and all its contents are replaced by the name of my custom function. Is it normal?
  • amieldylan-1340932731873398834

    Amiel Dylan

    26 days ago

    1340932731609284680-Capture_decran_2025-02-17_a_07.27.49.png
  • andreasmoller-1340933067627298928

    Andreas Møller

    26 days ago

    That happens when your customer formula throws an exception
  • amieldylan-1340934784821760123

    Amiel Dylan

    26 days ago

    I deleted the function but it didn't change anything. is there a way to rollback? I think I lost a significant part of my work
  • andreasmoller-1340935021430571018

    Andreas Møller

    26 days ago

    Are there any issues in the issue panel for that component?
  • amieldylan-1340936134787600394

    Amiel Dylan

    26 days ago

    The component I created is countryInput. but when I access it it marks removeAccent which is my custom function that I had created and then deleted.
    1340936133768511520-Capture_decran_2025-02-17_a_07.39.19.png
    1340936134099734528-Capture_decran_2025-02-17_a_07.41.01.png
    1340936134561235006-Capture_decran_2025-02-17_a_07.41.23.png
  • andreasmoller-1340936553874063421

    Andreas Møller

    26 days ago

    I am sorry I don’t quite understand
  • lucasg-1340936759470460949

    Lucas G

    26 days ago

    I’ve had a similar error happen. The function replaced the component path
  • lucasg-1340937029567119411

    Lucas G

    26 days ago

    You’ll need the team to give you a copy of your component so you can create a copy and delete the other one
  • amieldylan-1340937528471064617

    Amiel Dylan

    26 days ago

    Thanks @Lucas G . I apologize @Andreas Møller if my explanations do not seem clear. how do I proceed @Lucas G ?
  • lucasg-1340937751205253121

    Lucas G

    26 days ago

    It has to be someone from the team
  • @Erik Beuschau helped me out when this happened to me
  • lucasg-1340938086330400840

    Lucas G

    26 days ago

    Were you by any chance using undo when this happened? 🤔
  • amieldylan-1340938546453807196

    Amiel Dylan

    26 days ago

    Yes. I tried to go back when that happened. and when it didn't work I deleted the function that seemed to be a problem but nothing changed.
  • lucasg-1340938962012868692

    Lucas G

    26 days ago

    But were you undoing something then it broke is what I meant. Or do you happen to remember what you were doing when the component broke
  • I wasn’t able to reproduce it when it happened to me so trying to see if you remember how it happened
  • amieldylan-1340939628902879304

    Amiel Dylan

    26 days ago

    Yes, i replaced the content of my custom function from this :

    function removeAccents(args, ctx) {
    const accents = [
    { from: /[äâà]/g, to: 'a' },
    { from: /[éèê]/g, to: 'e' },
    { from: /[ïî]/g, to: 'i' },
    { from: /[ôö]/g, to: 'o' },
    { from: /[ûü]/g, to: 'u' }
    ];

    // Vérifie si la chaîne existe dans args
    if (!args.text || typeof args.text !== "string") {
    return "";
    }

    return accents.reduce((acc, rule) => acc.replace(rule.from, rule.to), args.text);
    }


    to this :

    function removeAccents(args, ctx) {
    if (!args.text || typeof args.text !== "string") {
    return "";
    }

    return args.text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
    }
  • amieldylan-1340940102276223008

    Amiel Dylan

    26 days ago

    The first version worked well, and I wanted to replace it with a lighter and simpler version
  • lucasg-1340941413394808934

    Lucas G

    26 days ago

    You’ll need to send the branch URL to someone from the team and the name of the component
  • amieldylan-1340941653934080062

    Amiel Dylan

    26 days ago

    Ok, thank you
  • amieldylan-1340942018985201715

    Amiel Dylan

    26 days ago

    I guess it would only work if I used to commit my changes often, which I don't do. I cross my fingers.
  • amieldylan-1340994805076987964

    Amiel Dylan

    26 days ago

    @Lucas G @Andreas Møller , I received the help I needed, @Erik Beuschau helped me a lot. Thank you very much!
    🙌2
    🙌2
  • Tod-1340994806809104455

    Tod

    26 days ago

    Great energy @Amiel Dylan! Your continuous contribution to the toddle Community just made you advance to Community Level 3!

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.