rainlab/translate-plugin

Translations inside plugins components not found?

snipiba opened this issue · 3 comments

I had a multiple components with twig shorthand {{ 'variable to translate'|_ }} and it is not found on backend and then is backend user not allowed to translate all variables inside plugins components.

Hi @snipiba

We may need some more information on this. I used this exact code inside my component and the Translate plugin found it:

image

code snippets from:
// layout

<section id="content">
  <div class="content-wrap">
   {% page %}
  </div>
</section>

// page

{% component 'billing' %}

// component

		<table class="table cart mb-5">
			<thead>
				<tr>
					<th class="cart-product-remove">&nbsp;</th>
					<th class="cart-product-thumbnail">&nbsp;</th>
					<th class="cart-product-name">{{ 'Product'|_ }}</th>
					<th class="cart-product-price">{{ 'Unit Price'|_ }}</th>
					<th class="cart-product-quantity">{{ 'Quantity'|_ }}</th>
					<th class="cart-product-subtotal">{{ 'Total'|_ }}</th>
				</tr>
			</thead>
			<tbody id="cart-table">
				{% partial __SELF__ ~ '::cartItems' basketSummary=basketSummary %}
			</tbody>

		</table>

/// and included partial ::cartItems is not found and translated...

<tr class="cart_item">
					<td colspan="6">
						<div class="row justify-content-between py-2 col-mb-30">
							<div class="col-lg-auto ps-lg-0">
								<form method="post"
										data-request="{{ __SELF__ }}::onApplyCoupon" 
										data-request-update="'{{ __SELF__ }}::cartItems' : '#cart-table','{{ __SELF__ }}::subtotals' : '#subtotals'" class="row">
									<div class="col-md-8">
										<input type="text" name="code" value="" class="sm-form-control text-center text-md-start" placeholder="{{ 'Enter Coupon Code'|_ }}.." />
									</div>
									<div class="col-md-4 mt-3 mt-md-0">
										<button type="submit"
												class="button button-3d button-black m-0">{{ 'Apply coupon / code'|_ }}</button>
									</div>
								</form>
							</div>
							<div class="col-lg-auto pe-lg-0">
								<a href="{{ 'cart/billing'|page }}" class="button button-3d mt-2 mt-sm-0 me-0">{{ 'continue' | _ }}</a>
							</div>
						</div>												
					</td>
				</tr>

This is fixed by 43a542a

Secondary component partials are not currently included in the scan. The change makes it so, but it depends on core version v3.4.11+