You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,58 @@ namespace :lokalise_custom do
127
127
end
128
128
```
129
129
130
+
## Multiple Lokalise projects
131
+
132
+
If your Rails app needs to sync with more than one Lokalise **project** (different `project_id`, possibly a different `api_token`), use `for_project` in `config/lokalise_rails.rb`. It registers a named, isolated config and automatically generates scoped rake tasks without changing the existing `lokalise_rails:import` and `lokalise_rails:export` tasks.
133
+
134
+
```ruby
135
+
# config/lokalise_rails.rb
136
+
137
+
# Main project — unchanged
138
+
LokaliseRails::GlobalConfig.config do |c|
139
+
c.api_token =ENV['LOKALISE_API_TOKEN']
140
+
c.project_id =ENV['LOKALISE_PROJECT_ID']
141
+
end
142
+
143
+
# Additional project
144
+
LokaliseRails::GlobalConfig.for_project(:mobile) do |c|
This generates the following rake tasks automatically:
151
+
152
+
```
153
+
rake lokalise_rails:import # existing - uses the main config
154
+
rake lokalise_rails:export # existing - uses the main config
155
+
rake lokalise_rails:mobile:import # auto-generated — uses the :mobile config
156
+
rake lokalise_rails:mobile:export # auto-generated — uses the :mobile config
157
+
```
158
+
159
+
Any setting not explicitly set in the `for_project` block falls back to the main `GlobalConfig` - so shared options like `api_token` only need to be written once:
160
+
161
+
```ruby
162
+
LokaliseRails::GlobalConfig.config do |c|
163
+
c.api_token =ENV['LOKALISE_API_TOKEN'] # shared by all projects
164
+
c.project_id =ENV['LOKALISE_PROJECT_ID']
165
+
end
166
+
167
+
LokaliseRails::GlobalConfig.for_project(:mobile) do |c|
168
+
# api_token is inherited from the main config above
> **Note:**`for_project` is designed for apps that need multiple distinct Lokalise **projects**. If you only need to sync multiple local directories against the same project, the `lokalise_custom` rake task pattern described above is sufficient.
181
+
130
182
## Configuration
131
183
132
184
Options are specified in the `config/lokalise_rails.rb` file.
0 commit comments