Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upLocalisation Wrapper #663
Conversation
jojolepro
added some commits
Apr 23, 2018
jojolepro
added
type: feature
pri: low
project: assets
status: ready
labels
Apr 24, 2018
torkleyy
reviewed
Apr 24, 2018
I recommend you use Progress to wait for the asset and then place the locale context somewhere in the world.
jojolepro
added
status: working
and removed
status: ready
labels
Apr 26, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jojolepro
Apr 26, 2018
Collaborator
Just realized I forget to rename things I copy pasted. Don't review now thanks ;)
|
Just realized I forget to rename things I copy pasted. Don't review now thanks ;) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Fixing now... |
jojolepro
added some commits
May 2, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Ready for review my dudes |
jojolepro
added
status: ready
and removed
status: working
labels
May 2, 2018
| + | ||
| +impl State for Example { | ||
| + fn on_start(&mut self, world: &mut World) { | ||
| + world.add_resource(AssetStorage::<Locale>::new()); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
May 2, 2018
Member
No longer needed, you add Processor<Locale> below, which will register this resource.
Rhuagh
May 2, 2018
Member
No longer needed, you add Processor<Locale> below, which will register this resource.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jojolepro
May 2, 2018
Collaborator
@torkleyy Its not useful in this case as ProgressCounter is made when batch loading multiple assets to prevent checking them one by one.
|
@torkleyy Its not useful in this case as ProgressCounter is made when batch loading multiple assets to prevent checking them one by one. |
| + let store = world.read_resource::<AssetStorage<Locale>>(); | ||
| + // Check if the locale has been loaded. | ||
| + // If you are doing this for multiple assets, you should be using `ProgressCounter`. | ||
| + if let Some(locale) = store.get(&self.handle.clone().unwrap()) { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| +fn main() { | ||
| + let resources_directory = format!("{}/examples/assets", env!("CARGO_MANIFEST_DIR")); | ||
| + let mut game = Application::build(resources_directory, Example::new()) | ||
| + .expect("Fatal error") |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| @@ -3,6 +3,20 @@ use std::sync::Arc; | ||
| use amethyst_core::specs::storage::UnprotectedStorage; | ||
| #[cfg(feature = "profiler")] | ||
| #[macro_use] | ||
| +#[cfg(feature = "profiler")] |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| @@ -9,6 +9,14 @@ use amethyst_core::specs::storage::UnprotectedStorage; | ||
| #[macro_use] | ||
| #[cfg(feature = "profiler")] | ||
| #[macro_use] | ||
| +#[cfg(feature = "profiler")] |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
May 7, 2018
Member
Fix the conflicts and fix the review comment above and this is ready for merge.
|
Fix the conflicts and fix the review comment above and this is ready for merge. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jojolepro
May 7, 2018
Collaborator
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
#[cfg(feature = "profiler")]
#[macro_use]
use thread_profiler::{register_thread_with_profiler, write_profile};
I'm rolling back the formatting changes.
|
#[cfg(feature = "profiler")] I'm rolling back the formatting changes. |
jojolepro
added some commits
May 2, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Done |
torkleyy
reviewed
May 7, 2018
Thanks for the fixes and cleanup, I have some more comments.
| + let store = world.read_resource::<AssetStorage<Locale>>(); | ||
| + | ||
| + // Check if the locale has been loaded. | ||
| + // If you are doing this for multiple assets, you should be using `ProgressCounter`. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| + .context | ||
| + .get_message("hello") | ||
| + .and_then(|msg| locale.context.format(msg, None)) | ||
| + .unwrap() |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Moxinilian
reviewed
May 10, 2018
How does one conveniently load and use multiple languages with this architecture?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Moxinilian
May 10, 2018
Contributor
I've seen that already, and ironically enough I could not find anything about that.
Does that mean we have to create a Locale for every language? If so, that means we have to conditionally get the asset everywhere, right?
|
I've seen that already, and ironically enough I could not find anything about that. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Conflictomania, but apart from that ready I believe? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Should be |
Rhuagh
added
status: review comments
and removed
status: ready
labels
May 17, 2018
torkleyy
approved these changes
May 28, 2018
Please add another language and address the comment, then we can merge this.
| + | ||
| +impl State for Example { | ||
| + fn on_start(&mut self, world: &mut World) { | ||
| + world.add_resource(AssetStorage::<Locale>::new()); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
soon I know I say that often ;) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jojolepro
Jun 15, 2018
Collaborator
Just updating the branch, will try to finish this thing this weekend. I'm not sure what changed last month so I don't know how much changes I need to make yet.
|
Just updating the branch, will try to finish this thing this weekend. I'm not sure what changed last month so I don't know how much changes I need to make yet. |
| @@ -152,12 +152,17 @@ name = "appendix_a" | ||
| path = "examples/appendix_a/main.rs" | ||
| [[example]] | ||
| +<<<<<<< HEAD |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
rustfmt pass 1 sec |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Ready for merge yay. :D |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
missing changelog entry |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jojolepro
Jun 27, 2018
Collaborator
Ready for real now! (I totally forgot I had to update the changelog for a full week :P )
|
Ready for real now! (I totally forgot I had to update the changelog for a full week :P ) |
jojolepro commentedApr 24, 2018
•
edited by torkleyy
Edited 1 time
-
torkleyy
edited Apr 24, 2018 (most recent)
Wraps a localisation context in a Asset wrapper.
Slightly inconvenient to use because we have to wait for the asset to be loaded, but I'm not sure how to go around that.
This change is