Skip to content

Disagreements in token type are not handled correctly #30

@JakeWharton

Description

@JakeWharton

res/values/strings.xml:

<resources>
  <string name="library_text_argument">{name, date}</string>
</resources>

res/values-es/strings.xml:

<resources>
  <string name="library_text_argument">{name, number}</string>
</resources>

Currently this produces:

public object FormattedResources {
  public fun library_text_argument(name: Instant): FormattedResource {
    val arguments = ArrayMap<String, Any>(1)
    arguments.put("name", Date.from(name))
    return FormattedResource(
      id = R.string.library_text_argument,
      arguments = arguments
    )
  }

  public fun library_text_argument(name: Number): FormattedResource {
    val arguments = ArrayMap<String, Any>(1)
    arguments.put("name", name)
    return FormattedResource(
      id = R.string.library_text_argument,
      arguments = arguments
    )
  }
}

I suspect we simply want to enforce the types to match across all configurations and fail the build otherwise.

Are there any cases where you might want to have multiple types for a single token? Solutions to this depend on #29 a bit, since a workaround for that would be to name them differently (provided we allow this with an XML attribute somehow). Then at the callsite you would have to do library_text_argument(nameDate = someInstance, nameNumber = 12).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions