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
Update the provider user_agent
#420
Conversation
) | ||
|
||
linux_processors = ('i686', 'x86_64',) | ||
|
||
mac_processors = ('Intel', 'PPC', 'U; Intel', 'U; PPC',) | ||
|
||
langs = ('en-US', 'sl-SI', 'it-IT',) | ||
# Language codes from ISO 639-1 | ||
langs = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from what I've seen, user agent strings usually use a locale (eg: en-us
) rather than languages.
Maybe this can be refactored to make use of https://github.com/joke2k/faker/blob/master/faker/providers/misc/__init__.py#L71, and you can exapnd the list there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a mistake to use language codes in UA strings.
A quote from this page:
The golden rule when creating language tags is to keep the tag as short as possible. Avoid region, script or other subtags except where they add useful distinguishing information. For instance, use ja for Japanese and not ja-JP, unless there is a particular reason that you need to say that this is Japanese as spoken in Japan, rather than elsewhere.
Herefrom. I think we should not care about using region code. It won't influence on something.
I will transfer the language codes to the provider misc
and use the method language_code
from it in the provider user_agent
. Will it be OK?
And the method locale
is very rough because it returns some weird things: it_QA
, el_IN
, el_PA
. I think, I will fix it soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using just language might be technically better, but I think the purpose of Faker
is to generate data as close as possible to what the user may actually encounter in practice.
In other words, it's technically correct and considered best practice to use just the language, but how common is it in practice for user agent string? Does it happen often?
For the same reason, I agree that the locale
method needs to be fixed.
@@ -163,6 +182,13 @@ def internet_explorer(cls): | |||
random.randint(0, 1)) | |||
|
|||
@classmethod | |||
def microsoft_edge(cls): | |||
tmplt = ('Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this have some part randomized?
314f86b
to
73f1259
Compare
@fcurella, I won't add Microsoft Edge UA in the PR. |
Thanks! ✨ |
No description provided.