(res, {
allowOverrides = false
} = {})
| 1948 | return this._messages.get(id); |
| 1949 | } |
| 1950 | addResource(res, { |
| 1951 | allowOverrides = false |
| 1952 | } = {}) { |
| 1953 | const errors = []; |
| 1954 | for (let i = 0; i < res.body.length; i++) { |
| 1955 | let entry = res.body[i]; |
| 1956 | if (entry.id.startsWith("-")) { |
| 1957 | if (allowOverrides === false && this._terms.has(entry.id)) { |
| 1958 | errors.push(new Error(`Attempt to override an existing term: "${entry.id}"`)); |
| 1959 | continue; |
| 1960 | } |
| 1961 | this._terms.set(entry.id, entry); |
| 1962 | } else { |
| 1963 | if (allowOverrides === false && this._messages.has(entry.id)) { |
| 1964 | errors.push(new Error(`Attempt to override an existing message: "${entry.id}"`)); |
| 1965 | continue; |
| 1966 | } |
| 1967 | this._messages.set(entry.id, entry); |
| 1968 | } |
| 1969 | } |
| 1970 | return errors; |
| 1971 | } |
| 1972 | formatPattern(pattern, args = null, errors = null) { |
| 1973 | if (typeof pattern === "string") { |
| 1974 | return this._transform(pattern); |
no test coverage detected