faker icon indicating copy to clipboard operation
faker copied to clipboard

Question: How faker parse and find data/list for format like {{ last_name }} - {{ first-name }} ?

Open gunungpw opened this issue 1 year ago • 4 comments

Hello new to faker codebase, i have question how faker parse the format tokenName and how its gets the reference for the data of that token name, I want to make company name with locale Indonesia (id_ID) with Indonesian name company or Indonesian last_name, But I am new to programming and not understand how the codebase work, do i need to make last_names data/list in id_ID locale for faker.person __init__.py and faker will automatically chose the last_name with Indonesia locale or i need do something else? Thank you

gunungpw avatar Jan 20 '24 04:01 gunungpw

when i search last_name data/list/tuple/dict i just find last_names (with "s" plural), I cannot find last_name data

gunungpw avatar Jan 20 '24 04:01 gunungpw

Where did you read about the placeholders? What is your current code?

stefan6419846 avatar Jan 20 '24 10:01 stefan6419846

https://github.com/joke2k/faker/blob/faa419b7af433c75253374c3d319ba5ffc3139cd/faker/providers/company/id_ID/init.py#L3C1-L11

How to track down {{ last_name }}? And how to use last_name that uses id_ID locale data?

class Provider(CompanyProvider):
    formats = (
        "{{company_prefix}} {{last_name}}",
        "{{company_prefix}} {{last_name}} {{last_name}}",
        "{{company_prefix}} {{last_name}} {{company_suffix}}",
        "{{company_prefix}} {{last_name}} {{last_name}} {{company_suffix}}",
    )

Thankyou

gunungpw avatar Jan 20 '24 11:01 gunungpw

The logic is handled in https://github.com/joke2k/faker/blob/faa419b7af433c75253374c3d319ba5ffc3139cd/faker/generator.py#L161 The corresponding values are retrieved from the corresponding providers - the company_suffix from the company provider, the last_name from the person provider. The last name should already use the localized values as far as I understand the code.

stefan6419846 avatar Jan 20 '24 14:01 stefan6419846

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 20 '24 01:04 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 04 '24 01:05 github-actions[bot]