Find object

Benchmark created on


Description

Find translation of field

Setup

const i18nLanguage === 'en'; // as per locale settings, any translation librray give us this

//to map backend response
const languageID i18nLanguage === 'en' ? 1 : '2'

let deptoName;
if ( descriptionData .length > 0) {
     const record = descriptionData.filter((item: any)=>item.language_id === languageID);
     if (record.length > 0) {
            deptoName = record[0]?.name;
      }
}        
                   

Test runner

Ready to run.

Testing in
TestOps/sec
TEST 1
[ {
        "language_id": 1,
        "language_name": "English",
        "translation_key_id": 421,
        "name": "Lending"
    },
    {
        "language_id": 2,
        "language_name": "French",
        "translation_key_id": 421,
        "name": "Approbation"
    }
    {
        "language_id": 3,
        "language_name": "Spanish",
        "translation_key_id": 421,
        "name": "Aprobacion"
    }
]
ready
TEST 2
[ {
        "language_id": 1,
        "language_name": "English",
        "translation_key_id": 421,
        "name": "Fraud"
    },
     {
        "language_id": 3,
        "language_name": "Spanish",
        "translation_key_id": 421,
        "name": "Fraude in spanish"
    }
    {
        "language_id": 2,
        "language_name": "French",
        "translation_key_id": 421,
        "name": "Fraude in french"
    }
]
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.