Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gunungpw opened this issue Jan 20, 2024 · 6 comments
Labels

Comments

@gunungpw
Copy link

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
Copy link
Author

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

@stefan6419846
Copy link
Contributor

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

@gunungpw
Copy link
Author

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

@stefan6419846
Copy link
Contributor

The logic is handled in

def parse(self, text: str) -> str:
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.

Copy link

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

@github-actions github-actions bot added the stale label Apr 20, 2024
Copy link

github-actions bot commented May 4, 2024

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants