Skip to content

Commit c555be5

Browse files
committed
Merge fixes
1 parent b9f0886 commit c555be5

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

fluent-bundle/src/bundle.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ pub struct Message {
2828
/// # Examples
2929
///
3030
/// ```
31-
/// use fluent::bundle::FluentBundle;
32-
/// use fluent::types::FluentValue;
31+
/// use fluent_bundle::bundle::FluentBundle;
32+
/// use fluent_bundle::resource::FluentResource;
33+
/// use fluent_bundle::types::FluentValue;
3334
/// use std::collections::HashMap;
3435
///
36+
/// let resource = FluentResource::try_new("intro = Welcome, { $name }.".to_string()).unwrap();
3537
/// let mut bundle = FluentBundle::new(&["en-US"]);
36-
/// bundle.add_messages("intro = Welcome, { $name }.");
38+
/// bundle.add_resource(&resource);
3739
///
3840
/// let mut args = HashMap::new();
3941
/// args.insert("name", FluentValue::from("Rustacean"));
@@ -89,7 +91,7 @@ impl<'bundle> FluentBundle<'bundle> {
8991
/// # Examples
9092
///
9193
/// ```
92-
/// use fluent::bundle::FluentBundle;
94+
/// use fluent_bundle::bundle::FluentBundle;
9395
///
9496
/// let mut bundle = FluentBundle::new(&["en-US"]);
9597
/// ```
@@ -120,11 +122,14 @@ impl<'bundle> FluentBundle<'bundle> {
120122
/// # Examples
121123
///
122124
/// ```
123-
/// use fluent::bundle::FluentBundle;
125+
/// use fluent_bundle::bundle::FluentBundle;
126+
/// use fluent_bundle::resource::FluentResource;
124127
///
128+
/// let resource = FluentResource::try_new("hello = Hi!".to_string()).unwrap();
125129
/// let mut bundle = FluentBundle::new(&["en-US"]);
126-
/// bundle.add_messages("hello = Hi!");
130+
/// bundle.add_resource(&resource);
127131
/// assert_eq!(true, bundle.has_message("hello"));
132+
///
128133
/// ```
129134
pub fn has_message(&self, id: &str) -> bool {
130135
self.entries.get_message(id).is_some()
@@ -140,18 +145,20 @@ impl<'bundle> FluentBundle<'bundle> {
140145
/// # Examples
141146
///
142147
/// ```
143-
/// use fluent::bundle::FluentBundle;
144-
/// use fluent::types::FluentValue;
148+
/// use fluent_bundle::bundle::FluentBundle;
149+
/// use fluent_bundle::resource::FluentResource;
150+
/// use fluent_bundle::types::FluentValue;
145151
///
152+
/// let resource = FluentResource::try_new("length = { STRLEN(\"12345\") }".to_string()).unwrap();
146153
/// let mut bundle = FluentBundle::new(&["en-US"]);
154+
/// bundle.add_resource(&resource);
147155
///
148156
/// // Register a fn that maps from string to string length
149157
/// bundle.add_function("STRLEN", |positional, _named| match positional {
150158
/// [Some(FluentValue::String(str))] => Some(FluentValue::Number(str.len().to_string())),
151159
/// _ => None,
152160
/// }).unwrap();
153161
///
154-
/// bundle.add_messages("length = { STRLEN(\"12345\") }").unwrap();
155162
/// let (value, _) = bundle.format("length", None).unwrap();
156163
/// assert_eq!(&value, "5");
157164
/// ```
@@ -182,13 +189,15 @@ impl<'bundle> FluentBundle<'bundle> {
182189
/// # Examples
183190
///
184191
/// ```
185-
/// use fluent::bundle::FluentBundle;
192+
/// use fluent_bundle::bundle::FluentBundle;
193+
/// use fluent_bundle::resource::FluentResource;
186194
///
187-
/// let mut bundle = FluentBundle::new(&["en-US"]);
188-
/// bundle.add_messages("
195+
/// let resource = FluentResource::try_new("
189196
/// hello = Hi!
190197
/// goodbye = Bye!
191-
/// ");
198+
/// ".to_string()).unwrap();
199+
/// let mut bundle = FluentBundle::new(&["en-US"]);
200+
/// bundle.add_resource(&resource);
192201
/// assert_eq!(true, bundle.has_message("hello"));
193202
/// ```
194203
///
@@ -248,12 +257,14 @@ impl<'bundle> FluentBundle<'bundle> {
248257
/// # Examples
249258
///
250259
/// ```
251-
/// use fluent::bundle::FluentBundle;
252-
/// use fluent::types::FluentValue;
260+
/// use fluent_bundle::bundle::FluentBundle;
261+
/// use fluent_bundle::resource::FluentResource;
262+
/// use fluent_bundle::types::FluentValue;
253263
/// use std::collections::HashMap;
254264
///
265+
/// let resource = FluentResource::try_new("intro = Welcome, { $name }.".to_string()).unwrap();
255266
/// let mut bundle = FluentBundle::new(&["en-US"]);
256-
/// bundle.add_messages("intro = Welcome, { $name }.");
267+
/// bundle.add_resource(&resource);
257268
///
258269
/// let mut args = HashMap::new();
259270
/// args.insert("name", FluentValue::from("Rustacean"));
@@ -266,14 +277,16 @@ impl<'bundle> FluentBundle<'bundle> {
266277
/// An example with attributes and no args:
267278
///
268279
/// ```
269-
/// use fluent::bundle::FluentBundle;
280+
/// use fluent_bundle::bundle::FluentBundle;
281+
/// use fluent_bundle::resource::FluentResource;
270282
///
271-
/// let mut bundle = FluentBundle::new(&["en-US"]);
272-
/// bundle.add_messages("
283+
/// let resource = FluentResource::try_new("
273284
/// hello =
274285
/// .title = Hi!
275286
/// .tooltip = This says 'Hi!'
276-
/// ");
287+
/// ".to_string()).unwrap();
288+
/// let mut bundle = FluentBundle::new(&["en-US"]);
289+
/// bundle.add_resource(&resource);
277290
///
278291
/// let value = bundle.format("hello.title", None);
279292
/// assert_eq!(value, Some(("Hi!".to_string(), vec![])));
@@ -291,18 +304,6 @@ impl<'bundle> FluentBundle<'bundle> {
291304
/// `path` itself as the formatted string. Sometimes, but not always,
292305
/// these partial failures will emit extra error information in the
293306
/// second term of the return tuple.
294-
///
295-
/// ```
296-
/// use fluent::bundle::FluentBundle;
297-
///
298-
/// // Create a message with bad cyclic reference
299-
/// let mut bundle = FluentBundle::new(&["en-US"]);
300-
/// bundle.add_messages("foo = a { foo } b");
301-
///
302-
/// // The result falls back to "___"
303-
/// let value = bundle.format("foo", None);
304-
/// assert_eq!(value, Some(("___".to_string(), vec![])));
305-
/// ```
306307
pub fn format(
307308
&self,
308309
path: &str,
@@ -354,7 +355,6 @@ impl<'bundle> FluentBundle<'bundle> {
354355
None
355356
}
356357

357-
/// Use [`format`](./struct.FluentBundle.html#method.format) instead.
358358
pub fn format_message(
359359
&self,
360360
message_id: &str,

0 commit comments

Comments
 (0)