-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add multiple source fields #223
Add multiple source fields #223
Conversation
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.
This is good to go as soon as the localization issues are resolved. Thanks!
modules/presets/index.js
Outdated
keys: ['source' + id, 'source' + id + ':url', 'source' + id + ':name', 'source' + id + ':date'], | ||
key: id, | ||
keys: [id, id + ':url', id + ':name', id + ':date'], | ||
overrideLabel: 'Source ' + i, |
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.
This still needs to be localized. You can define a format string in the localization and pass in the number as a parameter to replace the token in the format string:
Lines 766 to 767 in cb779ea
# format for the label of a feature that has a name and date range | |
dated: "{name} [{dateRange}]" |
Line 5 in cb779ea
import { t, localizer } from '../core/localizer'; |
Line 219 in cb779ea
return dateRange ? t('inspector.display_name.dated', {dateRange: dateRange, name: name}) : name; |
/ref #224
modules/presets/index.js
Outdated
let id = 'source' + (i > 0 ? ':' + i.toString() : ''); | ||
let previousId = 'source' + ((i-1) > 0 ? ':' + (i-1).toString() : ''); |
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.
Minor: String.prototype.toString()
is suitable for Western languages, but not for some other languages we support, like Persian. Number.prototype.toLocaleString
automatically adapts the number to the given writing system. Fortunately, you can just pass a number into the t
function and it’ll do the right thing.
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.
This String.prototype.toString()
is being used to define the source:2
key. If the "2" is localized, couldn't that cause problems? With the key ending up like source:٢
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.
Oh, you’re right, you’re only appending i
to “Source” below. So as long as you pass i
into the t()
call for that field name, it should work fine.
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.
Thanks, looks good!
This PR implements multiple source fields.
To use them, a user first has to write something in any of the inputs in the first "Source" field, then go to Add field -> Source 2. If something is written in any "Source 2" input, the user will be able to add "Source 3", and so on up to "Source 4".
The first source field will still be mapped to source=* / source:name=* , while the next source fields will be mapped to source:2=* / source:2:name=*