A Lexeme page currently has two places to enter a language code: the language code associated with the lemma and the language code associated with the representation. As a user I expect them to accept the same input. Currently the input for the language code of the lemma is correct and the input for the language code of the representation should be adjusted.
Acceptance criteria
- It is impossible to add a lemma using an invalid language code
- It is impossible to add a form representation using an invalid language code
Invalid language code here means any string other then the valid language code, defined for the scope of this task as follows:
- the string which is a language code recognized as valid by "core" wikibase
- if the input contains a part '-x-' in it, the part before '-x-' is a language code recognized as valid by "core" wikibase, and the part after '-x-' is of form: 'Q' followed by digits
Examples of valid language codes
- de
- de-at
- de-x-Q1996
Examples of invalid language codes
- foobar
- de-Q1996
- de-x-foobar
- de-x-Q1996-foobar
- foobar-x-Q1996
Scenarios
Invalid language code for lemma
GIVEN I am on the lexeme page
AND I click edit button of the lexeme header
AND I click add lemma button
WHEN I enter lemma text
AND I enter invalid language code
AND I click save
AND I reload the page
THEN I see the lemma with invalid language code has not been saved
Invalid language code for representation
GIVEN I am on the page of a lexeme with a form
AND I click edit button of the form
AND I click add representation button
WHEN I enter representation text
AND I enter invalid language code
AND I click save
AND I reload the page
THEN I see the representation with invalid language code has not been saved
Code pointer: the entered lang code is checked using validator provided by LexemeValidatorFactory::getLanguageCodeValidator
NOTE: as of 25.04.2018 the language code validation is not strict enough, as "de-x-foobar" would be recognized as the valid language, whereas it has been defined that a valid language code should include a Q-ID-like string after '-x-' tag.