getMessageKey function
Implementation
MessageKey getMessageKey(String jsonKey) {
String key;
MessageType type;
SubType? subType;
if (jsonKey.endsWith('One')) {
key = jsonKey.substring(0, jsonKey.lastIndexOf('One'));
type = MessageType.plural;
subType = SubType.pluralOne;
} else if (jsonKey.endsWith('Few')) {
key = jsonKey.substring(0, jsonKey.lastIndexOf('Few'));
type = MessageType.plural;
subType = SubType.pluralFew;
} else if (jsonKey.endsWith('Many')) {
key = jsonKey.substring(0, jsonKey.lastIndexOf('Many'));
type = MessageType.plural;
subType = SubType.pluralMany;
} else if (jsonKey.endsWith('POther')) {
key = jsonKey.substring(0, jsonKey.lastIndexOf('POther'));
type = MessageType.plural;
subType = SubType.pluralOther;
} else if (jsonKey.endsWith('Zero')) {
key = jsonKey.substring(0, jsonKey.lastIndexOf('Zero'));
type = MessageType.plural;
subType = SubType.pluralZero;
} else if (jsonKey.endsWith('Two')) {
key = jsonKey.substring(0, jsonKey.lastIndexOf('Two'));
type = MessageType.plural;
subType = SubType.pluralTwo;
} else if (jsonKey.endsWith('Male')) {
key = jsonKey.substring(0, jsonKey.lastIndexOf('Male'));
type = MessageType.gender;
subType = SubType.genderMale;
} else if (jsonKey.endsWith('Female')) {
key = jsonKey.substring(0, jsonKey.lastIndexOf('Female'));
type = MessageType.gender;
subType = SubType.genderFemale;
} else if (jsonKey.endsWith('GOther')) {
key = jsonKey.substring(0, jsonKey.lastIndexOf('GOther'));
type = MessageType.gender;
subType = SubType.genderOther;
} else {
key = jsonKey;
type = MessageType.message;
}
return MessageKey(key, type, subType);
}