https://github.com/square/phrase
Phrase is an Android string resource templating library
https://github.com/square/phrase
Last synced: 9 months ago
JSON representation
Phrase is an Android string resource templating library
- Host: GitHub
- URL: https://github.com/square/phrase
- Owner: square
- License: apache-2.0
- Created: 2014-01-22T00:51:50.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2023-03-18T23:29:21.000Z (almost 3 years ago)
- Last Synced: 2024-10-29T17:55:10.486Z (about 1 year ago)
- Language: Java
- Size: 161 KB
- Stars: 1,404
- Watchers: 44
- Forks: 126
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-android-ui - https://github.com/square/phrase
- awesome-java - Phrase
- awesome-android-libraries - phrase
README
Phrase - Android string formatting
==================================
[](https://raw.githubusercontent.com/square/phrase/master/LICENSE.txt) [](http://maven-repository.com/artifact/com.squareup.phrase) [](https://travis-ci.org/square/phrase)
```java
CharSequence formatted = Phrase.from("Hi {first_name}, you are {age} years old.")
.put("first_name", firstName)
.put("age", age)
.format();
```
Send your phrase straight into a TextView:
```java
Phrase.from("Welcome back {user}.")
.put("user", name)
.into(textView);
```
Comma-separated lists:
```
CharSequence formattedList = ListPhrase.from(", ")
.join(1, 2, 3);
// returns "1, 2, 3"
```
English sentence-style lists:
```
ListPhrase listFormatter = ListPhrase.from(
" and ",
", ",
", and ");
listFormatter.join(Arrays.asList(1, 2));
// returns "1 and 2"
listFormatter.join(Arrays.asList(1, 2, 3));
// returns "1, 2, and 3"
```
Download
--------
You can download [the latest jar here][jar].
You can also depend on the .jar through Maven:
```xml
com.squareup.phrase
phrase
(insert latest version)
```
or through Gradle:
```groovy
dependencies {
compile 'com.squareup.phrase:phrase:(insert latest version)'
}
```
License
-------
Copyright 2013 Square, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
[jar]: http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.squareup.phrase&a=phrase&v=LATEST